Author: tkreuzer
Date: Fri Nov 22 11:36:22 2013
New Revision: 61071

URL: http://svn.reactos.org/svn/reactos?rev=61071&view=rev
Log:
[VIDEOPRT]
Handle IOCTL_VIDEO_USE_DEVICE_IN_SESSION

Modified:
    trunk/reactos/include/psdk/ntddvdeo.h
    trunk/reactos/win32ss/drivers/videoprt/dispatch.c
    trunk/reactos/win32ss/drivers/videoprt/videoprt.c
    trunk/reactos/win32ss/drivers/videoprt/videoprt.h

Modified: trunk/reactos/include/psdk/ntddvdeo.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ntddvdeo.h?rev=61071&r1=61070&r2=61071&view=diff
==============================================================================
--- trunk/reactos/include/psdk/ntddvdeo.h       [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/ntddvdeo.h       [iso-8859-1] Fri Nov 22 
11:36:22 2013
@@ -264,6 +264,11 @@
   OUT HANDLE pPhysDeviceObject;
   OUT ULONG DualviewFlags;
 } VIDEO_WIN32K_CALLBACKS, *PVIDEO_WIN32K_CALLBACKS;
+
+typedef struct _VIDEO_DEVICE_SESSION_STATUS {
+  ULONG bEnable;
+  ULONG bSuccess;
+} VIDEO_DEVICE_SESSION_STATUS, *PVIDEO_DEVICE_SESSION_STATUS;
 
 typedef struct _VIDEO_MEMORY {
   PVOID RequestedVirtualAddress;
@@ -559,6 +564,7 @@
 #define DISPLAYPOLICY_DC                0x00000002
 #define DISPLAYPOLICY_BOTH              0x00000003
 
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/reactos/win32ss/drivers/videoprt/dispatch.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/videoprt/dispatch.c?rev=61071&r1=61070&r2=61071&view=diff
==============================================================================
--- trunk/reactos/win32ss/drivers/videoprt/dispatch.c   [iso-8859-1] (original)
+++ trunk/reactos/win32ss/drivers/videoprt/dispatch.c   [iso-8859-1] Fri Nov 22 
11:36:22 2013
@@ -289,13 +289,75 @@
 
 static
 NTSTATUS
+VideoPortUseDeviceInSesion(
+    _Inout_ PDEVICE_OBJECT DeviceObject,
+    _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState,
+    _In_ ULONG BufferLength,
+    _Out_ PULONG_PTR Information)
+{
+    PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
+
+    /* Check buffer size */
+    *Information = sizeof(VIDEO_DEVICE_SESSION_STATUS);
+    if (BufferLength < sizeof(VIDEO_DEVICE_SESSION_STATUS))
+    {
+        ERR_(VIDEOPRT, "Buffer too small for VIDEO_DEVICE_SESSION_STATUS: 
%lx\n",
+             BufferLength);
+        return STATUS_BUFFER_TOO_SMALL;
+    }
+
+    /* Get the device extension */
+    DeviceExtension = DeviceObject->DeviceExtension;
+
+    /* Shall we enable the session? */
+    if (SessionState->bEnable)
+    {
+        /* Check if we have no session yet */
+        if (DeviceExtension->SessionId == -1)
+        {
+            /* Use this session and return success */
+            DeviceExtension->SessionId = PsGetCurrentProcessSessionId();
+            SessionState->bSuccess = TRUE;
+        }
+        else
+        {
+            ERR_(VIDEOPRT, "Requested to set session, but session is already 
set to: 0x%lx",
+                 DeviceExtension->SessionId);
+            SessionState->bSuccess = FALSE;
+        }
+    }
+    else
+    {
+        /* Check if we belong to the current session */
+        if (DeviceExtension->SessionId == PsGetCurrentProcessSessionId())
+        {
+            /* Reset the session and return success */
+            DeviceExtension->SessionId = -1;
+            SessionState->bSuccess = TRUE;
+        }
+        else
+        {
+            ERR_(VIDEOPRT, "Requested to reset session, but session is not 
set\n");
+            SessionState->bSuccess = FALSE;
+        }
+    }
+
+    return STATUS_SUCCESS;
+}
+
+static
+NTSTATUS
 VideoPortInitWin32kCallbacks(
-    IN PDEVICE_OBJECT DeviceObject,
-    PVIDEO_WIN32K_CALLBACKS Win32kCallbacks,
-    ULONG BufferLength)
-{
+    _In_ PDEVICE_OBJECT DeviceObject,
+    _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks,
+    _In_ ULONG BufferLength,
+    _Out_ PULONG_PTR Information)
+{
+    *Information = sizeof(VIDEO_WIN32K_CALLBACKS);
     if (BufferLength < sizeof(VIDEO_WIN32K_CALLBACKS))
     {
+        ERR_(VIDEOPRT, "Buffer too small for VIDEO_WIN32K_CALLBACKS: %lx\n",
+             BufferLength);
         return STATUS_BUFFER_TOO_SMALL;
     }
 
@@ -401,7 +463,16 @@
             INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
             Status = VideoPortInitWin32kCallbacks(DeviceObject,
                                                   
Irp->AssociatedIrp.SystemBuffer,
-                                                  
IrpStack->Parameters.DeviceIoControl.InputBufferLength);
+                                                  
IrpStack->Parameters.DeviceIoControl.InputBufferLength,
+                                                  &Irp->IoStatus.Information);
+            break;
+
+        case IOCTL_VIDEO_USE_DEVICE_IN_SESSION:
+            INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
+            Status = VideoPortUseDeviceInSesion(DeviceObject,
+                                                
Irp->AssociatedIrp.SystemBuffer,
+                                                
IrpStack->Parameters.DeviceIoControl.InputBufferLength,
+                                                &Irp->IoStatus.Information);
             break;
 
         default:

Modified: trunk/reactos/win32ss/drivers/videoprt/videoprt.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/videoprt/videoprt.c?rev=61071&r1=61070&r2=61071&view=diff
==============================================================================
--- trunk/reactos/win32ss/drivers/videoprt/videoprt.c   [iso-8859-1] (original)
+++ trunk/reactos/win32ss/drivers/videoprt/videoprt.c   [iso-8859-1] Fri Nov 22 
11:36:22 2013
@@ -150,6 +150,7 @@
     DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
     DeviceExtension->FunctionalDeviceObject = *DeviceObject;
     DeviceExtension->DriverExtension = DriverExtension;
+    DeviceExtension->SessionId = -1;
 
     InitializeListHead(&DeviceExtension->ChildDeviceList);
 

Modified: trunk/reactos/win32ss/drivers/videoprt/videoprt.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/drivers/videoprt/videoprt.h?rev=61071&r1=61070&r2=61071&view=diff
==============================================================================
--- trunk/reactos/win32ss/drivers/videoprt/videoprt.h   [iso-8859-1] (original)
+++ trunk/reactos/win32ss/drivers/videoprt/videoprt.h   [iso-8859-1] Fri Nov 22 
11:36:22 2013
@@ -31,6 +31,7 @@
 #include <ndk/kefuncs.h>
 #include <ndk/rtlfuncs.h>
 #include <ndk/obfuncs.h>
+#include <ndk/psfuncs.h>
 
 #define __BROKEN__
 #include <miniport.h>
@@ -113,6 +114,7 @@
    AGP_BUS_INTERFACE_STANDARD AgpInterface;
    KMUTEX DeviceLock;
    LIST_ENTRY DmaAdapterList, ChildDeviceList;
+   ULONG SessionId;
    CHAR MiniPortDeviceExtension[1];
 } VIDEO_PORT_DEVICE_EXTENSION, *PVIDEO_PORT_DEVICE_EXTENSION;
 


Reply via email to