]> xenbits.xensource.com Git - pvdrivers/win/xencons.git/commitdiff
Respond to non-default console IOCTLs
authorOwen Smith <owen.smith@citrix.com>
Fri, 2 Mar 2018 11:55:23 +0000 (11:55 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Fri, 2 Mar 2018 11:56:04 +0000 (11:56 +0000)
Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/xencons/frontend.c

index 731150dc77d810ab111bd6b0c0f2ddafa54a561c..08da84596d179b9c0820f1785f440727d9f9a1de 100644 (file)
@@ -1168,6 +1168,80 @@ FrontendSuspend(
     Trace("<====\n");
 }
 
+static NTSTATUS
+FrontendGetProperty(
+    IN  PXENCONS_FRONTEND   Frontend,
+    IN  PIRP                Irp
+    )
+{
+    PIO_STACK_LOCATION      StackLocation;
+    ULONG                   IoControlCode;
+    ULONG                   InputBufferLength;
+    ULONG                   OutputBufferLength;
+    PVOID                   Buffer;
+    PCHAR                   Value;
+    ULONG                   Length;
+    NTSTATUS                status;
+
+    StackLocation = IoGetCurrentIrpStackLocation(Irp);
+    IoControlCode = StackLocation->Parameters.DeviceIoControl.IoControlCode;
+    InputBufferLength = StackLocation->Parameters.DeviceIoControl.InputBufferLength;
+    OutputBufferLength = StackLocation->Parameters.DeviceIoControl.OutputBufferLength;
+    Buffer = Irp->AssociatedIrp.SystemBuffer;
+
+    switch (IoControlCode) {
+    case IOCTL_XENCONS_GET_INSTANCE:
+        Value = PdoGetName(Frontend->Pdo);
+        break;
+    case IOCTL_XENCONS_GET_NAME:
+        Value = Frontend->Name;
+        break;
+    case IOCTL_XENCONS_GET_PROTOCOL:
+        Value = Frontend->Protocol;
+        break;
+    default:
+        Value = NULL;
+        break;
+    }
+
+    status = STATUS_NOT_SUPPORTED;
+    if (Value == NULL)
+        goto fail1;
+
+    status = STATUS_INVALID_PARAMETER;
+    if (InputBufferLength != 0)
+        goto fail2;
+
+    Length = (ULONG)strlen(Value) + 1;
+    Irp->IoStatus.Information = Length;
+
+    status = STATUS_INVALID_BUFFER_SIZE;
+    if (OutputBufferLength == 0)
+        goto fail3;
+
+    RtlZeroMemory(Buffer, OutputBufferLength);
+    if (OutputBufferLength < Length)
+        goto fail4;
+
+    RtlCopyMemory(Buffer, Value, Length);
+
+    return STATUS_SUCCESS;
+
+fail4:
+    Error("fail4\n");
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    Error("fail2\n");
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
 static NTSTATUS
 FrontendAbiAcquire(
     IN  PXENCONS_CONSOLE_ABI_CONTEXT    Context
@@ -1321,10 +1395,23 @@ FrontendAbiPutQueue(
     IN  PIRP                            Irp
     )
 {
-    UNREFERENCED_PARAMETER(Context);
-    UNREFERENCED_PARAMETER(Irp);
+    PXENCONS_FRONTEND                   Frontend = (PXENCONS_FRONTEND)Context;
+    PIO_STACK_LOCATION                  StackLocation;
+
+    StackLocation = IoGetCurrentIrpStackLocation(Irp);
+
+    switch (StackLocation->MajorFunction) {
+    case IRP_MJ_READ:
+    case IRP_MJ_WRITE:
+        return STATUS_DEVICE_NOT_READY;
 
-    return STATUS_DEVICE_NOT_READY;
+    case IRP_MJ_DEVICE_CONTROL:
+        return FrontendGetProperty(Frontend, Irp);
+
+    default:
+        ASSERT(FALSE);
+        return STATUS_NOT_SUPPORTED;
+    }
 }
 
 static XENCONS_CONSOLE_ABI FrontendAbi = {