Jump to content

DosDevIOCtl: Difference between revisions

From EDM2
Created page with "==Syntax== Performs control functions on a device specified by an opened device handle. <pre> #define INCL_DOSDEVICES #define INCL_DOSDEVIOCTL #include <os2.h> hDe..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Syntax==
Performs control functions on a device specified by an opened device handle.
Performs control functions on a device specified by an opened device handle.


==Syntax==
DosDevIOCtl(hDevice, category, function, pParams, cbParmLenMax,
            pcbParmLen, pData, cbDataLenMax, pcbDataLen)


<pre>
===Parameters===
#define INCL_DOSDEVICES
;hDevice ([[HFILE]]) - input:Device handle returned by [[DosOpen]], or a standard (open) device handle.
#define INCL_DOSDEVIOCTL
;category (ULONG) - input :Device category.
#include &lt;os2.h&gt;
:The valid range is 0 to 255.
 
;function (ULONG) - input :Device-specific function code.
[[hDevice]];      /*  Device handle returned by [[DosOpen]], or a standard (open) device handle. */
:The valid range is 0 to 255.
[[category]];      /*  Device category. */
;pParams (PVOID) - input :Address of the command-specific argument list.
[[function]];      /*  Device-specific function code. */
;cbParmLenMax (ULONG) - input : Length, in bytes, of pParams.
[[pParams]];      /*  Address of the command-specific argument list. */
:This is the maximum length of the data to be returned in pParams. pcbParmLen may be larger than this on input, but not on output.
[[cbParmLenMax]];  /*  Length, in bytes, of ''pParams''. */
;pcbParmLen (PULONG) - in/out : Pointer to the length of parameters.
[[pcbParmLen]];   /Pointer to the length of parameters. */
:Input: Pointer to the length, in bytes, of the parameters passed in pParams. by the application.
[[pData]];        /*  Address of the data area. */
:Output: Pointer to the length, in bytes, of the parameters returned.
[[cbDataLenMax]];  /*  Length, in bytes, of ''pData''. */
:If this function returns ERROR_BUFFER_OVERFLOW, then pcbParmLen points to the size of the buffer required to hold the parameters returned. No other data is returned in this case.
[[pcbDataLen]];   /Pointer to the length of data. */
;pData (PVOID) - input: Address of the data area.
[[ulrc]];          /*  Return Code. */
;cbDataLenMax (ULONG) - input: Length, in bytes, of pData.
:This is the maximum length of the data to be returned in pData. pcbDataLen may be larger than this on input, but not on output.
; pcbDataLen (PULONG) - in/out : Pointer to the length of data.
:Input: Pointer to the length, in bytes, of the data passed by the application in pData.
:Output: Pointer to the length, in bytes, of the data returned.
:If this function returns ERROR_BUFFER_OVERFLOW, then pcbDataLen points to the size of the buffer required to hold the data returned.


ulrc = DosDevIOCtl(hDevice, category, function,
===Return Code===
        pParams, cbParmLenMax, pcbParmLen,
;ulrc (APIRET) - returns:DosDevIOCtl returns one of the following values:
        pData, cbDataLenMax, pcbDataLen);
* 0 NO_ERROR
 
* 1 ERROR_INVALID_FUNCTION
</pre>
* 6 ERROR_INVALID_HANDLE
 
* 15 ERROR_INVALID_DRIVE
==Parameters==
* 31 ERROR_GEN_FAILURE
hDevice (HFILE) - input
* 87 ERROR_INVALID_PARAMETER
 
* 111 ERROR_BUFFER_OVERFLOW
    Device handle returned by DosOpen, or a standard (open) device handle.
* 115 ERROR_PROTECTION_VIOLATION
 
* 117 ERROR_INVALID_CATEGORY
category (ULONG) - input
* 119 ERROR_BAD_DRIVER_LEVEL
 
* 163 ERROR_UNCERTAIN_MEDIA
    Device category.
* 165 ERROR_MONITORS_NOT_SUPPORTED
 
    The valid range is 0 to 255.
 
function (ULONG) - input
 
    Device-specific function code.
 
    The valid range is 0 to 255.
 
pParams (PVOID) - input
 
    Address of the command-specific argument list.
 
cbParmLenMax (ULONG) - input
 
    Length, in bytes, of pParams.
 
    This is the maximum length of the data to be returned in pParams. pcbParmLen may be larger than this on input, but not on output.
 
pcbParmLen (PULONG) - in/out
 
    Pointer to the length of parameters.
 
    Input
        Pointer to the length, in bytes, of the parameters passed in pParams. by the application. Output
        Pointer to the length, in bytes, of the parameters returned.
 
        If this function returns ERROR_BUFFER_OVERFLOW, then pcbParmLen points to the size of the buffer required to hold the parameters returned. No other data is returned in this case.
 
    pData (PVOID) - input
        Address of the data area.
 
    cbDataLenMax (ULONG) - input
        Length, in bytes, of pData.
 
        This is the maximum length of the data to be returned in pData. pcbDataLen may be larger than this on input, but not on output.
 
    pcbDataLen (PULONG) - in/out
        Pointer to the length of data.
 
        Input
            Pointer to the length, in bytes, of the data passed by the application in pData. Output
            Pointer to the length, in bytes, of the data returned.
 
            If this function returns ERROR_BUFFER_OVERFLOW, then pcbDataLen points to the size of the buffer required to hold the data returned.
 
        ulrc (APIRET) - returns
            Return Code.
 
            DosDevIOCtl returns one of the following values:
 
            NO_ERROR 1
                ERROR_INVALID_FUNCTION 6
                ERROR_INVALID_HANDLE 15
                ERROR_INVALID_DRIVE 31
                ERROR_GEN_FAILURE 87
                ERROR_INVALID_PARAMETER 111
                ERROR_BUFFER_OVERFLOW 115
                ERROR_PROTECTION_VIOLATION 117
                ERROR_INVALID_CATEGORY 119
                ERROR_BAD_DRIVER_LEVEL 163
                ERROR_UNCERTAIN_MEDIA 165
                ERROR_MONITORS_NOT_SUPPORTED For a full list of error codes, see Errors.
 
==Returns==
ulrc (APIRET) - returns
 
    Return Code.
 
    DosDevIOCtl returns one of the following values:
 
    NO_ERROR
    ERROR_INVALID_FUNCTION
    ERROR_INVALID_HANDLE
    15
        ERROR_INVALID_DRIVE 31
        ERROR_GEN_FAILURE 87
        ERROR_INVALID_PARAMETER 111
        ERROR_BUFFER_OVERFLOW 115
        ERROR_PROTECTION_VIOLATION 117
        ERROR_INVALID_CATEGORY 119
        ERROR_BAD_DRIVER_LEVEL 163
        ERROR_UNCERTAIN_MEDIA 165
        ERROR_MONITORS_NOT_SUPPORTED For a full list of error codes, see Errors.


==Remarks==
==Remarks==
Values returned in the range 0xFF00 through 0xFFFF are user-dependent error codes. Values returned in the range 0xFE00 through 0xFEFF are device-driver-dependent error codes.
Values returned in the range 0xFF00 through 0xFFFF are user-dependent error codes. Values returned in the range 0xFE00 through 0xFEFF are device-driver-dependent error codes.


This function provides a generic, expandable IOCtl facility.
This function provides a generic, expandable IOCtl facility.
Line 133: Line 56:
See Generic IOCtl Commands for a complete listing of the generic IOCtl control functions (the IOCtl interface).
See Generic IOCtl Commands for a complete listing of the generic IOCtl control functions (the IOCtl interface).


For debugging considerations, see DosDebug.  
For debugging considerations, see [[DosDebug]].


==Example Code==
==Example Code==
The following is NOT a complete C program. It is simply intended to provide
The following is NOT a complete C program. It is simply intended to provide an idea of how to issue control functions to a device.
an idea of how to issue control functions to a device.


 
This example assumes that DevHandle contains the handle to the device, and that the device recognizes category code hex 83, function code hex 1D and the input parameters and input data area.
This example assumes that DevHandle contains the handle to the device, and
<pre>
that the device recognizes category code hex 83, function code hex 1D and
#define INCL_DOSDEVICES  /* Device values */
the input parameters and input data area.
 
 
<pre> #define INCL_DOSDEVICES  /* Device values */
  #define INCL_DOSERRORS    /* Error values */
  #define INCL_DOSERRORS    /* Error values */
  #include &lt;os2.h&gt;
  #include <os2.h>
  #include &lt;stdio.h&gt;
  #include <stdio.h>
  #include &lt;string.h&gt;
  #include <string.h>


  HFILE  DevHandle        = NULLHANDLE;  /* Handle for device */
  HFILE  DevHandle        = NULLHANDLE;  /* Handle for device */
Line 171: Line 89:
                   uchParms,            /* Input/Output parameter list */
                   uchParms,            /* Input/Output parameter list */
                   sizeof(uchParms),    /* Maximum output parameter size */
                   sizeof(uchParms),    /* Maximum output parameter size */
                   &amp;ulParmLen,          /* Input:  size of parameter list */
                   &ulParmLen,          /* Input:  size of parameter list */
                                         /* Output: size of parameters returned */
                                         /* Output: size of parameters returned */
                   uchDataArea,        /* Input/Output data area */
                   uchDataArea,        /* Input/Output data area */
                   sizeof(uchDataArea), /* Maximum output data size */
                   sizeof(uchDataArea), /* Maximum output data size */
                   &amp;ulDataLen);        /* Input:  size of input data area */
                   &ulDataLen);        /* Input:  size of input data area */
                                         /* Output: size of data returned  */
                                         /* Output: size of data returned  */


Line 182: Line 100:
       return 1;
       return 1;
   }
   }
</pre>
</pre>


==Related Functions==
==Related Functions==
* DosBeep
* [[DosBeep]]
* DosDevConfig
* [[DosDevConfig]]
* DosPhysicalDisk  
* [[DosPhysicalDisk]]


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 17:57, 28 February 2020

Performs control functions on a device specified by an opened device handle.

Syntax

DosDevIOCtl(hDevice, category, function, pParams, cbParmLenMax,
            pcbParmLen, pData, cbDataLenMax, pcbDataLen)

Parameters

hDevice (HFILE) - input
Device handle returned by DosOpen, or a standard (open) device handle.
category (ULONG) - input
Device category.
The valid range is 0 to 255.
function (ULONG) - input
Device-specific function code.
The valid range is 0 to 255.
pParams (PVOID) - input
Address of the command-specific argument list.
cbParmLenMax (ULONG) - input
Length, in bytes, of pParams.
This is the maximum length of the data to be returned in pParams. pcbParmLen may be larger than this on input, but not on output.
pcbParmLen (PULONG) - in/out
Pointer to the length of parameters.
Input: Pointer to the length, in bytes, of the parameters passed in pParams. by the application.
Output: Pointer to the length, in bytes, of the parameters returned.
If this function returns ERROR_BUFFER_OVERFLOW, then pcbParmLen points to the size of the buffer required to hold the parameters returned. No other data is returned in this case.
pData (PVOID) - input
Address of the data area.
cbDataLenMax (ULONG) - input
Length, in bytes, of pData.
This is the maximum length of the data to be returned in pData. pcbDataLen may be larger than this on input, but not on output.
pcbDataLen (PULONG) - in/out
Pointer to the length of data.
Input: Pointer to the length, in bytes, of the data passed by the application in pData.
Output: Pointer to the length, in bytes, of the data returned.
If this function returns ERROR_BUFFER_OVERFLOW, then pcbDataLen points to the size of the buffer required to hold the data returned.

Return Code

ulrc (APIRET) - returns
DosDevIOCtl returns one of the following values:
  • 0 NO_ERROR
  • 1 ERROR_INVALID_FUNCTION
  • 6 ERROR_INVALID_HANDLE
  • 15 ERROR_INVALID_DRIVE
  • 31 ERROR_GEN_FAILURE
  • 87 ERROR_INVALID_PARAMETER
  • 111 ERROR_BUFFER_OVERFLOW
  • 115 ERROR_PROTECTION_VIOLATION
  • 117 ERROR_INVALID_CATEGORY
  • 119 ERROR_BAD_DRIVER_LEVEL
  • 163 ERROR_UNCERTAIN_MEDIA
  • 165 ERROR_MONITORS_NOT_SUPPORTED

Remarks

Values returned in the range 0xFF00 through 0xFFFF are user-dependent error codes. Values returned in the range 0xFE00 through 0xFEFF are device-driver-dependent error codes.

This function provides a generic, expandable IOCtl facility.

A null (zero) value for pData specifies that this parameter is not defined for the generic IOCtl function being specified. A null value for pData causes the values passed in cbDataLenMax and pcbDataLen to be ignored.

A null (zero) value for pParams specifies that this parameter is not defined for the generic IOCtl function being specified. A null value for pParams causes the values passed in cbParmLenMax and pcbParmLen to be ignored.

The kernel formats a generic IOCtl packet and calls the device driver. Because OS/2 Version 1.0 and Version 1.1 device drivers do not understand generic IOCtl packets with cbDataLenMax, pcbDataLen, cbParmLenMax, and pcbParmLen, the kernel does not pass these fields to the device driver. Device drivers that are marked as level 2 or higher must support receipt of the generic IOCtl packets with associated length fields.

Do not pass a non-null pointer with a zero length.

See Generic IOCtl Commands for a complete listing of the generic IOCtl control functions (the IOCtl interface).

For debugging considerations, see DosDebug.

Example Code

The following is NOT a complete C program. It is simply intended to provide an idea of how to issue control functions to a device.

This example assumes that DevHandle contains the handle to the device, and that the device recognizes category code hex 83, function code hex 1D and the input parameters and input data area.

 #define INCL_DOSDEVICES   /* Device values */
 #define INCL_DOSERRORS    /* Error values */
 #include <os2.h>
 #include <stdio.h>
 #include <string.h>

 HFILE   DevHandle        = NULLHANDLE;   /* Handle for device */
 ULONG   ulCategory       = 0x83;         /* Device category */
 ULONG   ulFunction       = 0x1D;         /* Device-specific function */
 UCHAR   uchParms[120]    = {0};          /* Input and output for function */
 ULONG   ulParmLen        = 0;            /* Input and output parameter size */
 UCHAR   uchDataArea[200] = {0};          /* Input and output data area */
 ULONG   ulDataLen        = 0;            /* Input and output data size */
 APIRET  rc               = NO_ERROR;     /* Return code */

  strcpy(uchParms,"/X /Y /Z");    /* Input parameters */
  ulParmLen = strlen(uchParms);   /* Length of input parameters */

  strcpy(uchDataArea,"DF=123;NP=BCR;UN=1993;MAX=328");  /* Input data */
  ulDataLen = strlen(uchDataArea);                      /* Length of data  */

  rc = DosDevIOCtl(DevHandle,           /* Handle to device */
                   ulCategory,          /* Category of request */
                   ulFunction,          /* Function being requested */
                   uchParms,            /* Input/Output parameter list */
                   sizeof(uchParms),    /* Maximum output parameter size */
                   &ulParmLen,          /* Input:  size of parameter list */
                                        /* Output: size of parameters returned */
                   uchDataArea,         /* Input/Output data area */
                   sizeof(uchDataArea), /* Maximum output data size */
                   &ulDataLen);         /* Input:  size of input data area */
                                        /* Output: size of data returned   */

  if (rc != NO_ERROR) {
      printf("DosDevIOCtl error: return code = %u\n", rc);
      return 1;
  }

Related Functions