[KSECDD]
[reactos.git] / reactos / drivers / crypto / ksecdd / dispatch.c
index c1726df..fe6be34 100644 (file)
@@ -81,6 +81,35 @@ KsecQueryVolumeInformation(
     return STATUS_SUCCESS;
 }
 
+static
+NTSTATUS
+KsecDeviceControl(
+    ULONG IoControlCode,
+    PVOID Buffer,
+    SIZE_T InputLength,
+    PSIZE_T OutputLength)
+{
+    NTSTATUS Status;
+
+    Status = STATUS_SUCCESS;
+
+    /* Check ioctl code */
+    switch (IoControlCode)
+    {
+        case IOCTL_KSEC_GEN_RANDOM:
+
+            Status = KsecGenRandom(Buffer, *OutputLength);
+            break;
+
+        default:
+            DPRINT1("Unhandled control code 0x%lx\n", IoControlCode);
+            __debugbreak();
+            return STATUS_INVALID_PARAMETER;
+    }
+
+    return Status;
+}
+
 NTSTATUS
 NTAPI
 KsecDdDispatch(
@@ -91,9 +120,10 @@ KsecDdDispatch(
     ULONG_PTR Information;
     NTSTATUS Status;
     PVOID Buffer;
-    SIZE_T OutputLength;
+    SIZE_T InputLength, OutputLength;
     FILE_INFORMATION_CLASS FileInfoClass;
     FS_INFORMATION_CLASS FsInfoClass;
+    ULONG IoControlCode;
 
     IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
 
@@ -149,6 +179,22 @@ KsecDdDispatch(
             Information = OutputLength;
             break;
 
+        case IRP_MJ_DEVICE_CONTROL:
+
+            /* Extract the parameters */
+            Buffer = Irp->AssociatedIrp.SystemBuffer;
+            InputLength = IoStackLocation->Parameters.DeviceIoControl.InputBufferLength;
+            OutputLength = IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength;
+            IoControlCode = IoStackLocation->Parameters.DeviceIoControl.IoControlCode;
+
+            /* Call the internal function */
+            Status = KsecDeviceControl(IoControlCode,
+                                       Buffer,
+                                       InputLength,
+                                       &OutputLength);
+            Information = OutputLength;
+            break;
+
         default:
             DPRINT1("Unhandled major function %lu!\n",
                     IoStackLocation->MajorFunction);