Keep the following points in mind when implementing a new DispatchDeviceControl or DispatchInternalDeviceControl routine:
Such a higher-level driver should propagate the status value returned by IoCallDriver or set in the returned IRP’s I/O status block when it returns control for a request that lower drivers handle synchronously.
if (Irp->Parameters.DeviceIoControl.InputBufferLength <
(sizeof(IOCTL_SPECIFIC_STRUCTURE))) { status = STATUS_XXX;
or
if (Irp->Parameters.DeviceIoControl.OutputBufferLength <
(sizeof(IOCTL_SPECIFIC_STRUCTURE))) { status = STATUS_XXX;
where the status value set is one of STATUS_BUFFER_TOO_SMALL or STATUS_INVALID_PARAMETER.