00001 /*++ 00002 00003 Copyright (c) 1989-1993 Microsoft Corporation 00004 00005 Module Name: 00006 00007 devctrl.c 00008 00009 Abstract: 00010 00011 This module contains the code to implement the NtDeviceIoControlFile system 00012 service for the NT I/O system. 00013 00014 Author: 00015 00016 Darryl E. Havens (darrylh) 16-Oct-1989 00017 00018 Environment: 00019 00020 Kernel mode only 00021 00022 Revision History: 00023 00024 00025 --*/ 00026 00027 #include "iop.h" 00028 00029 #ifdef ALLOC_PRAGMA 00030 #pragma alloc_text(PAGE, NtDeviceIoControlFile) 00031 #endif 00032 00033 NTSTATUS 00034 NtDeviceIoControlFile( 00035 IN HANDLE FileHandle, 00036 IN HANDLE Event OPTIONAL, 00037 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, 00038 IN PVOID ApcContext OPTIONAL, 00039 OUT PIO_STATUS_BLOCK IoStatusBlock, 00040 IN ULONG IoControlCode, 00041 IN PVOID InputBuffer OPTIONAL, 00042 IN ULONG InputBufferLength, 00043 OUT PVOID OutputBuffer OPTIONAL, 00044 IN ULONG OutputBufferLength 00045 ) 00046 00047 /*++ 00048 00049 Routine Description: 00050 00051 This service builds descriptors or MDLs for the supplied buffer(s) and 00052 passes the untyped data to the device driver associated with the file 00053 handle. It is up to the driver to check the input data and function 00054 IoControlCode for validity, as well as to make the appropriate access 00055 checks. 00056 00057 Arguments: 00058 00059 FileHandle - Supplies a handle to the file on which the service is being 00060 performed. 00061 00062 Event - Supplies an optional event to be set to the Signaled state when 00063 the service is complete. 00064 00065 ApcRoutine - Supplies an optional APC routine to be executed when the 00066 service is complete. 00067 00068 ApcContext - Supplies a context parameter to be passed to the ApcRoutine, 00069 if an ApcRoutine was specified. 00070 00071 IoStatusBlock - Address of the caller's I/O status block. 00072 00073 IoControlCode - Subfunction code to determine exactly what operation is 00074 being performed. 00075 00076 InputBuffer - Optionally supplies an input buffer to be passed to the 00077 device driver. Whether or not the buffer is actually optional is 00078 dependent on the IoControlCode. 00079 00080 InputBufferLength - Length of the InputBuffer in bytes. 00081 00082 OutputBuffer - Optionally supplies an output buffer to receive information 00083 from the device driver. Whether or not the buffer is actually optional 00084 is dependent on the IoControlCode. 00085 00086 OutputBufferLength - Length of the OutputBuffer in bytes. 00087 00088 Return Value: 00089 00090 The status returned is success if the control operation was properly 00091 queued to the I/O system. Once the operation completes, the status 00092 can be determined by examining the Status field of the I/O status block. 00093 00094 --*/ 00095 00096 { 00097 // 00098 // Simply invoke the common routine that implements both device and file 00099 // system I/O controls. 00100 // 00101 00102 return IopXxxControlFile( FileHandle, 00103 Event, 00104 ApcRoutine, 00105 ApcContext, 00106 IoStatusBlock, 00107 IoControlCode, 00108 InputBuffer, 00109 InputBufferLength, 00110 OutputBuffer, 00111 OutputBufferLength, 00112 TRUE ); 00113 }