ReactOS  0.4.15-dev-1197-g8081ba9
dispatch.c File Reference
#include "videoprt.h"
#include <ndk/inbvfuncs.h>
#include <ndk/obfuncs.h>
#include <ndk/psfuncs.h>
#include <debug.h>
Include dependency graph for dispatch.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static VOID VideoPortWin32kCallout (_In_ PVIDEO_WIN32K_CALLBACKS_PARAMS CallbackParams)
 
static BOOLEAN NTAPI IntVideoPortResetDisplayParametersEx (_In_ ULONG Columns, _In_ ULONG Rows, _In_ BOOLEAN CalledByInbv)
 
static BOOLEAN NTAPI IntVideoPortResetDisplayParameters (ULONG Columns, ULONG Rows)
 
static VOID NTAPI InbvMonitorThread (_In_ PVOID Context)
 
static NTSTATUS IntVideoPortInbvInitialize (VOID)
 
static NTSTATUS IntVideoPortInbvCleanup (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI IntVideoPortAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS NTAPI IntVideoPortDispatchOpen (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
PSTR IoctlName (ULONG Ioctl)
 
static NTSTATUS VideoPortUseDeviceInSession (_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
 
static NTSTATUS VideoPortInitWin32kCallbacks (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
 
static NTSTATUS VideoPortForwardDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortPnPStartDevice (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortForwardIrpAndWaitCompletionRoutine (PDEVICE_OBJECT Fdo, PIRP Irp, PVOID Context)
 
NTSTATUS NTAPI IntVideoPortQueryBusRelations (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortForwardIrpAndWait (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchFdoPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchCleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchPower (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchSystemControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI IntVideoPortUnload (PDRIVER_OBJECT DriverObject)
 

Variables

static PVIDEO_WIN32K_CALLOUT Win32kCallout = NULL
 
static HANDLE InbvThreadHandle = NULL
 
static BOOLEAN InbvMonitoring = FALSE
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 28 of file dispatch.c.

Function Documentation

◆ InbvMonitorThread()

static VOID NTAPI InbvMonitorThread ( _In_ PVOID  Context)
static

Definition at line 208 of file dispatch.c.

210 {
211  VIDEO_WIN32K_CALLBACKS_PARAMS CallbackParams;
212  LARGE_INTEGER Delay;
213  USHORT i;
214 
216 
217  while (TRUE)
218  {
219  /*
220  * During one second, check the INBV status each 100 milliseconds,
221  * then revert to 1 second delay.
222  */
223  i = 10;
224  Delay.QuadPart = (LONGLONG)-100*1000*10; // 100 millisecond delay
225  while (!InbvMonitoring)
226  {
228 
229  if ((i > 0) && (--i == 0))
230  Delay.QuadPart = (LONGLONG)-1*1000*1000*10; // 1 second delay
231  }
232 
233  /*
234  * Loop while the display is owned by INBV. We cannot do anything else
235  * than polling since INBV does not offer a proper notification system.
236  *
237  * During one second, check the INBV status each 100 milliseconds,
238  * then revert to 1 second delay.
239  */
240  i = 10;
241  Delay.QuadPart = (LONGLONG)-100*1000*10; // 100 millisecond delay
242  while (InbvCheckDisplayOwnership())
243  {
245 
246  if ((i > 0) && (--i == 0))
247  Delay.QuadPart = (LONGLONG)-1*1000*1000*10; // 1 second delay
248  }
249 
250  /* Reset the monitoring */
252 
253  /*
254  * Somebody released INBV display ownership, usually by invoking
255  * InbvNotifyDisplayOwnershipLost(). However the caller of this
256  * function certainly specified a different callback than ours.
257  * As we are going to be the only owner of the active display,
258  * we need to re-register our own display reset callback.
259  */
261 
262  /* Tell Win32k to reset the display */
263  CallbackParams.CalloutType = VideoFindAdapterCallout;
264  // CallbackParams.PhysDisp = NULL;
265  CallbackParams.Param = (ULONG_PTR)TRUE; // TRUE: Re-enable display; FALSE: Disable display.
266  VideoPortWin32kCallout(&CallbackParams);
267  }
268 
269  // FIXME: See IntVideoPortInbvCleanup().
270  // PsTerminateSystemThread(STATUS_SUCCESS);
271 }
VOID NTAPI InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:638
static BOOLEAN InbvMonitoring
Definition: dispatch.c:35
VIDEO_WIN32K_CALLBACKS_PARAMS_TYPE CalloutType
Definition: ntddvdeo.h:249
#define TRUE
Definition: types.h:120
#define LOW_REALTIME_PRIORITY
static BOOLEAN NTAPI IntVideoPortResetDisplayParameters(ULONG Columns, ULONG Rows)
Definition: dispatch.c:168
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
int64_t LONGLONG
Definition: typedefs.h:68
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1327
unsigned short USHORT
Definition: pedump.c:61
static VOID VideoPortWin32kCallout(_In_ PVIDEO_WIN32K_CALLBACKS_PARAMS CallbackParams)
Definition: dispatch.c:40
#define ULONG_PTR
Definition: config.h:101
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:553
#define KeGetCurrentThread
Definition: hal.h:44
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by IntVideoPortInbvInitialize().

◆ IntVideoPortAddDevice()

NTSTATUS NTAPI IntVideoPortAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 334 of file dispatch.c.

337 {
341 
342  /* Get the initialization data we saved in VideoPortInitialize. */
344 
345  /* Create adapter device object. */
349  &DeviceObject);
350  if (NT_SUCCESS(Status))
352 
353  return Status;
354 }
NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject(_In_ PDRIVER_OBJECT DriverObject, _In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject, _Out_opt_ PDEVICE_OBJECT *DeviceObject)
Definition: videoprt.c:94
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1866
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
ULONG VideoPortDeviceNumber
Definition: videoprt.c:40
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchCleanup()

NTSTATUS NTAPI IntVideoPortDispatchCleanup ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 1097 of file dispatch.c.

1100 {
1101  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1102 
1103  DeviceExtension = DeviceObject->DeviceExtension;
1104  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
1105 
1106  Irp->IoStatus.Status = STATUS_SUCCESS;
1107  Irp->IoStatus.Information = 0;
1109 
1110  return STATUS_SUCCESS;
1111 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IO_NO_INCREMENT
Definition: iotypes.h:581
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ IntVideoPortDispatchClose()

NTSTATUS NTAPI IntVideoPortDispatchClose ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 429 of file dispatch.c.

432 {
433  TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
434 
436 
437  Irp->IoStatus.Status = STATUS_SUCCESS;
439  return STATUS_SUCCESS;
440 }
_In_ PIRP Irp
Definition: csq.h:116
static NTSTATUS IntVideoPortInbvCleanup(IN PDEVICE_OBJECT DeviceObject)
Definition: dispatch.c:300
#define IoCompleteRequest
Definition: irp.c:1240
#define TRACE_(x)
Definition: compat.h:76
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IO_NO_INCREMENT
Definition: iotypes.h:581
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchDeviceControl()

NTSTATUS NTAPI IntVideoPortDispatchDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 714 of file dispatch.c.

717 {
718  PIO_STACK_LOCATION IrpStack;
721 
722  TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
723 
724  IrpStack = IoGetCurrentIrpStackLocation(Irp);
725 
726  switch (IrpStack->MajorFunction)
727  {
729  /* This is the main part of this function and is handled below */
730  break;
731 
732  case IRP_MJ_SHUTDOWN:
733  {
734  /* Dereference CSRSS */
735  PKPROCESS OldCsrProcess;
736  OldCsrProcess = InterlockedExchangePointer((PVOID*)&CsrProcess, NULL);
737  if (OldCsrProcess)
738  ObDereferenceObject(OldCsrProcess);
739 
740  Irp->IoStatus.Status = STATUS_SUCCESS;
742  return STATUS_SUCCESS;
743  }
744 
745  default:
746  ERR_(VIDEOPRT, "- Unknown MajorFunction 0x%x\n", IrpStack->MajorFunction);
747  Irp->IoStatus.Status = STATUS_SUCCESS;
749  return STATUS_SUCCESS;
750  }
751 
752  IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
753 
754  INFO_(VIDEOPRT, "- IoControlCode: 0x%x: %s\n", IoControlCode, IoctlName(IoControlCode));
755 
756  switch (IoControlCode)
757  {
761  WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_VDM are UNIMPLEMENTED!\n");
763  break;
764 
767  WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_OUTPUT_DEVICE_POWER_STATE are UNIMPLEMENTED!\n");
769  break;
770 
773  WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_POWER_MANAGEMENT are UNIMPLEMENTED!\n");
775  break;
776 
780  WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_BRIGHTNESS are UNIMPLEMENTED!\n");
782  break;
783 
785  INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
787  Irp->AssociatedIrp.SystemBuffer,
788  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
789  &Irp->IoStatus.Information);
790  break;
791 
793  WARN_(VIDEOPRT, "- IOCTL_VIDEO_IS_VGA_DEVICE is UNIMPLEMENTED!\n");
795  break;
796 
798  INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
800  Irp->AssociatedIrp.SystemBuffer,
801  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
802  &Irp->IoStatus.Information);
803  break;
804 
806  INFO_(VIDEOPRT, "- IOCTL_VIDEO_PREPARE_FOR_EARECOVERY\n");
807  /*
808  * The Win32k Watchdog Timer detected that a thread spent more time
809  * in a display driver than the allotted time its threshold specified,
810  * and thus is going to attempt to recover by switching to VGA mode.
811  * If this attempt fails, the watchdog generates bugcheck 0xEA
812  * "THREAD_STUCK_IN_DEVICE_DRIVER".
813  *
814  * Prepare the recovery by resetting the display adapters to
815  * standard VGA 80x25 text mode.
816  */
819  break;
820 
821  default:
822  /* Forward to the Miniport Driver */
824  break;
825  }
826 
827  INFO_(VIDEOPRT, "- Returned status: 0x%x\n", Status);
828 
829  Irp->IoStatus.Status = Status;
831  return Status;
832 }
#define IOCTL_VIDEO_IS_VGA_DEVICE
Definition: ntddvdeo.h:68
static NTSTATUS VideoPortUseDeviceInSession(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:562
#define INFO_(ch,...)
Definition: debug.h:159
#define IOCTL_VIDEO_REGISTER_VDM
Definition: ntddvdeo.h:47
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_VIDEO_ENABLE_VDM
Definition: ntddvdeo.h:41
#define IOCTL_VIDEO_GET_POWER_MANAGEMENT
Definition: ntddvdeo.h:98
#define IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:53
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PKPROCESS CsrProcess
Definition: videoprt.c:39
PSTR IoctlName(ULONG Ioctl)
Definition: dispatch.c:443
_In_ ULONG IoControlCode
Definition: cdrom.h:1437
#define FALSE
Definition: types.h:117
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:62
smooth NULL
Definition: ftsmooth.c:416
static BOOLEAN NTAPI IntVideoPortResetDisplayParametersEx(_In_ ULONG Columns, _In_ ULONG Rows, _In_ BOOLEAN CalledByInbv)
Definition: dispatch.c:72
#define IoCompleteRequest
Definition: irp.c:1240
static NTSTATUS VideoPortInitWin32kCallbacks(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:620
#define IOCTL_VIDEO_SET_POWER_MANAGEMENT
Definition: ntddvdeo.h:170
#define TRACE_(x)
Definition: compat.h:76
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define IOCTL_VIDEO_PREPARE_FOR_EARECOVERY
Definition: ntddvdeo.h:74
#define IO_VIDEO_INCREMENT
Definition: iotypes.h:592
#define IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:200
Status
Definition: gdiplustypes.h:24
#define IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS
Definition: ntddvdeo.h:194
#define IOCTL_VIDEO_DISABLE_VDM
Definition: ntddvdeo.h:44
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:197
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
static NTSTATUS VideoPortForwardDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:647
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define IOCTL_VIDEO_USE_DEVICE_IN_SESSION
Definition: ntddvdeo.h:71
#define WARN_(ch,...)
Definition: debug.h:157
#define IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:50
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchFdoPnp()

NTSTATUS NTAPI IntVideoPortDispatchFdoPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 1006 of file dispatch.c.

1009 {
1011  NTSTATUS Status;
1012  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1013 
1015 
1016  switch (IrpSp->MinorFunction)
1017  {
1018  case IRP_MN_START_DEVICE:
1020  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
1022  Irp->IoStatus.Status = Status;
1023  Irp->IoStatus.Information = 0;
1025  break;
1026 
1029  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
1031  Irp->IoStatus.Status = Status;
1032  Irp->IoStatus.Information = 0;
1034  break;
1035 
1037  if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
1038  {
1040  Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1041  }
1042  else
1043  {
1045  Irp->IoStatus.Status = Status;
1047  }
1048  break;
1049 
1050  case IRP_MN_REMOVE_DEVICE:
1054 
1055  case IRP_MN_STOP_DEVICE:
1057  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
1059  Irp->IoStatus.Status = Status;
1060  Irp->IoStatus.Information = 0;
1062  break;
1063 
1067  Irp->IoStatus.Status = STATUS_SUCCESS;
1068  Irp->IoStatus.Information = 0;
1070  break;
1071 
1072  default:
1073  Status = Irp->IoStatus.Status;
1075  break;
1076  }
1077 
1078  return Status;
1079 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_REMOVE_DEVICE
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_MN_QUERY_REMOVE_DEVICE
NTSTATUS NTAPI IntVideoPortFilterResourceRequirements(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: resource.c:77
#define IoCompleteRequest
Definition: irp.c:1240
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MN_START_DEVICE
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
NTSTATUS NTAPI IntVideoPortForwardIrpAndWait(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatch.c:978
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
NTSTATUS NTAPI IntVideoPortPnPStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:836
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
NTSTATUS NTAPI IntVideoPortQueryBusRelations(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatch.c:930
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define IRP_MN_CANCEL_STOP_DEVICE
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by IntVideoPortDispatchPnp().

◆ IntVideoPortDispatchOpen()

NTSTATUS NTAPI IntVideoPortDispatchOpen ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 366 of file dispatch.c.

369 {
371  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
373 
374  TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n");
375 
376  if (!CsrProcess)
377  {
378  /*
379  * We know the first open call will be from the CSRSS process
380  * to let us know its handle.
381  */
382  INFO_(VIDEOPRT, "Referencing CSRSS\n");
385  INFO_(VIDEOPRT, "CsrProcess 0x%p\n", CsrProcess);
386 
388  if (!NT_SUCCESS(Status))
389  {
390  ERR_(VIDEOPRT, "IntInitializeVideoAddressSpace() failed: 0x%lx\n", Status);
392  CsrProcess = NULL;
393  return Status;
394  }
395  }
396 
397  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
398  DriverExtension = DeviceExtension->DriverExtension;
399 
400  // FIXME: (Re-)initialize INBV only if DeviceObject doesn't belong to a mirror driver.
402 
403  if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
404  {
405  Irp->IoStatus.Status = STATUS_SUCCESS;
406  InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
407  }
408  else
409  {
410  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
411  }
412 
413  Irp->IoStatus.Information = FILE_OPENED;
415 
416  return STATUS_SUCCESS;
417 }
#define INFO_(ch,...)
Definition: debug.h:159
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
_In_ PIRP Irp
Definition: csq.h:116
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
#define FILE_OPENED
Definition: nt_native.h:769
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PKPROCESS CsrProcess
Definition: videoprt.c:39
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI IntInitializeVideoAddressSpace(VOID)
Definition: int10.c:146
static NTSTATUS IntVideoPortInbvInitialize(VOID)
Definition: dispatch.c:274
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
#define InterlockedIncrement
Definition: armddk.h:53
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define ObReferenceObject
Definition: obfuncs.h:204
#define IO_NO_INCREMENT
Definition: iotypes.h:581
return STATUS_SUCCESS
Definition: btrfs.c:3014
signed int * PLONG
Definition: retypes.h:5

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPnp()

NTSTATUS NTAPI IntVideoPortDispatchPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 1083 of file dispatch.c.

1086 {
1087  PVIDEO_PORT_COMMON_EXTENSION CommonExtension = DeviceObject->DeviceExtension;
1088 
1089  if (CommonExtension->Fdo)
1091  else
1093 }
NTSTATUS NTAPI IntVideoPortDispatchPdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: child.c:319
NTSTATUS NTAPI IntVideoPortDispatchFdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1006
_In_ PIRP Irp
Definition: csq.h:116
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPower()

NTSTATUS NTAPI IntVideoPortDispatchPower ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 1115 of file dispatch.c.

1118 {
1120  NTSTATUS Status = Irp->IoStatus.Status;
1121  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1122 
1124 
1125  if (DeviceExtension->Common.Fdo)
1126  {
1129  return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1130  }
1131  else
1132  {
1133  switch (IrpSp->MinorFunction)
1134  {
1135  case IRP_MN_QUERY_POWER:
1136  case IRP_MN_SET_POWER:
1138  break;
1139  }
1141  Irp->IoStatus.Status = Status;
1143  return Status;
1144  }
1145 }
#define IRP_MN_QUERY_POWER
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
#define IRP_MN_SET_POWER
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:737
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
#define IO_NO_INCREMENT
Definition: iotypes.h:581
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchSystemControl()

NTSTATUS NTAPI IntVideoPortDispatchSystemControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 1149 of file dispatch.c.

1152 {
1153  NTSTATUS Status;
1154  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1155 
1156  if (DeviceExtension->Common.Fdo)
1157  {
1159  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1160  }
1161  else
1162  {
1163  Status = Irp->IoStatus.Status;
1165  return Status;
1166  }
1167 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by VideoPortInitialize().

◆ IntVideoPortForwardIrpAndWait()

NTSTATUS NTAPI IntVideoPortForwardIrpAndWait ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 978 of file dispatch.c.

979 {
980  KEVENT Event;
982  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension =
983  (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
984 
989  &Event,
990  TRUE,
991  TRUE,
992  TRUE);
993 
994  Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
995  if (Status == STATUS_PENDING)
996  {
998  Status = Irp->IoStatus.Status;
999  }
1000 
1001  return Status;
1002 }
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
NTSTATUS NTAPI IntVideoPortForwardIrpAndWaitCompletionRoutine(PDEVICE_OBJECT Fdo, PIRP Irp, PVOID Context)
Definition: dispatch.c:915
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2864
#define FALSE
Definition: types.h:117
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:450
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_PENDING
Definition: ntstatus.h:82
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

Referenced by IntVideoPortDispatchFdoPnp().

◆ IntVideoPortForwardIrpAndWaitCompletionRoutine()

NTSTATUS NTAPI IntVideoPortForwardIrpAndWaitCompletionRoutine ( PDEVICE_OBJECT  Fdo,
PIRP  Irp,
PVOID  Context 
)

Definition at line 915 of file dispatch.c.

919 {
921 
922  if (Irp->PendingReturned)
924 
926 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
_In_ PIRP Irp
Definition: csq.h:116
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define FALSE
Definition: types.h:117
struct tagContext Context
Definition: acpixf.h:1034
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by IntVideoPortForwardIrpAndWait().

◆ IntVideoPortInbvCleanup()

static NTSTATUS IntVideoPortInbvCleanup ( IN PDEVICE_OBJECT  DeviceObject)
static

Definition at line 300 of file dispatch.c.

302 {
303  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
304  // HANDLE ThreadHandle;
305 
306  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
307  if ((DeviceExtension->DeviceOpened >= 1) &&
308  (InterlockedDecrement((PLONG)&DeviceExtension->DeviceOpened) == 0))
309  {
310  // RemoveEntryList(&DeviceExtension->HwResetListEntry);
313  // or InbvAcquireDisplayOwnership(); ?
314  }
315 
316 #if 0
317  // TODO: Find the best way to communicate the request.
318  /* Signal the INBV monitoring thread and wait for it to terminate */
320  if (ThreadHandle)
321  {
323  /* Close its handle */
324  ObCloseHandle(ThreadHandle, KernelMode);
325  }
326 #endif
327 
328  return STATUS_SUCCESS;
329 }
VOID NTAPI InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:638
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
static BOOLEAN NTAPI IntVideoPortResetDisplayParametersEx(_In_ ULONG Columns, _In_ ULONG Rows, _In_ BOOLEAN CalledByInbv)
Definition: dispatch.c:72
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
static HANDLE InbvThreadHandle
Definition: dispatch.c:34
if(!(yy_init))
Definition: macro.lex.yy.c:714
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
#define InterlockedDecrement
Definition: armddk.h:52
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
return STATUS_SUCCESS
Definition: btrfs.c:3014
signed int * PLONG
Definition: retypes.h:5

Referenced by IntVideoPortDispatchClose().

◆ IntVideoPortInbvInitialize()

static NTSTATUS IntVideoPortInbvInitialize ( VOID  )
static

Definition at line 274 of file dispatch.c.

275 {
276  /* Create the INBV monitoring thread if needed */
277  if (!InbvThreadHandle)
278  {
281 
283  0,
285  NULL,
286  NULL,
288  NULL);
289  if (!NT_SUCCESS(Status))
291  }
292 
293  /* Re-register the display reset callback with INBV */
295 
296  return STATUS_SUCCESS;
297 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
VOID NTAPI InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:638
static VOID NTAPI InbvMonitorThread(_In_ PVOID Context)
Definition: dispatch.c:208
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
static BOOLEAN NTAPI IntVideoPortResetDisplayParameters(ULONG Columns, ULONG Rows)
Definition: dispatch.c:168
smooth NULL
Definition: ftsmooth.c:416
static HANDLE InbvThreadHandle
Definition: dispatch.c:34
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by IntVideoPortDispatchOpen().

◆ IntVideoPortPnPStartDevice()

NTSTATUS NTAPI IntVideoPortPnPStartDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 836 of file dispatch.c.

839 {
843  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
845 
846  /* Get the initialization data we saved in VideoPortInitialize.*/
847  DriverObject = DeviceObject->DriverObject;
849  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
850 
851  /* Store some resources in the DeviceExtension. */
852  AllocatedResources = Stack->Parameters.StartDevice.AllocatedResources;
854  {
855  CM_FULL_RESOURCE_DESCRIPTOR *FullList;
858  ULONG ResourceListSize;
859 
860  /* Save the resource list */
861  ResourceCount = AllocatedResources->List[0].PartialResourceList.Count;
862  ResourceListSize =
863  FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
864  PartialDescriptors[ResourceCount]);
865  DeviceExtension->AllocatedResources = ExAllocatePool(PagedPool, ResourceListSize);
866  if (DeviceExtension->AllocatedResources == NULL)
867  {
869  }
870 
871  RtlCopyMemory(DeviceExtension->AllocatedResources,
873  ResourceListSize);
874 
875  /* Get the interrupt level/vector - needed by HwFindAdapter sometimes */
876  FullList = AllocatedResources->List;
877  ASSERT(AllocatedResources->Count == 1);
878  INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
879  FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber, FullList->PartialResourceList.Version, FullList->PartialResourceList.Revision);
880 
881  /* FIXME: Is this ASSERT ok for resources from the PNP manager? */
882  ASSERT(FullList->InterfaceType == PCIBus);
883  ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
884  ASSERT(1 == FullList->PartialResourceList.Version);
885  ASSERT(1 == FullList->PartialResourceList.Revision);
887  Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
888  Descriptor++)
889  {
890  if (Descriptor->Type == CmResourceTypeInterrupt)
891  {
892  DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
893  DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
894  if (Descriptor->ShareDisposition == CmResourceShareShared)
895  DeviceExtension->InterruptShared = TRUE;
896  else
897  DeviceExtension->InterruptShared = FALSE;
898  }
899  }
900  }
901 
902  INFO_(VIDEOPRT, "Interrupt level: 0x%x Interrupt Vector: 0x%x\n",
903  DeviceExtension->InterruptLevel,
904  DeviceExtension->InterruptVector);
905 
906  /* Create adapter device object. */
909  DeviceObject);
910 }
NTSTATUS NTAPI IntVideoPortFindAdapter(IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT DeviceObject)
Definition: videoprt.c:254
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define INFO_(ch,...)
Definition: debug.h:159
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4640
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
PCM_RESOURCE_LIST AllocatedResources
Definition: videoprt.h:94
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
LIST_ENTRY List
Definition: psmgr.c:57
if(!(yy_init))
Definition: macro.lex.yy.c:714
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: cdrom.h:932
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static ULONG ResourceCount
Definition: inbv.c:92
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1866
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
unsigned int ULONG
Definition: retypes.h:1
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107

Referenced by IntVideoPortDispatchFdoPnp().

◆ IntVideoPortQueryBusRelations()

NTSTATUS NTAPI IntVideoPortQueryBusRelations ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 930 of file dispatch.c.

931 {
932  PDEVICE_RELATIONS DeviceRelations;
933  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
934  PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
935  ULONG i;
936  PLIST_ENTRY CurrentEntry;
937 
938  /* Count the children */
939  i = 0;
940  CurrentEntry = DeviceExtension->ChildDeviceList.Flink;
941  while (CurrentEntry != &DeviceExtension->ChildDeviceList)
942  {
943  i++;
944  CurrentEntry = CurrentEntry->Flink;
945  }
946 
947  if (i == 0)
948  return Irp->IoStatus.Status;
949 
950  DeviceRelations = ExAllocatePool(PagedPool,
951  sizeof(DEVICE_RELATIONS) + ((i - 1) * sizeof(PVOID)));
952  if (!DeviceRelations) return STATUS_NO_MEMORY;
953 
954  DeviceRelations->Count = i;
955 
956  /* Add the children */
957  i = 0;
958  CurrentEntry = DeviceExtension->ChildDeviceList.Flink;
959  while (CurrentEntry != &DeviceExtension->ChildDeviceList)
960  {
961  ChildExtension = CONTAINING_RECORD(CurrentEntry, VIDEO_PORT_CHILD_EXTENSION, ListEntry);
962 
963  ObReferenceObject(ChildExtension->PhysicalDeviceObject);
964  DeviceRelations->Objects[i] = ChildExtension->PhysicalDeviceObject;
965 
966  i++;
967  CurrentEntry = CurrentEntry->Flink;
968  }
969 
970  INFO_(VIDEOPRT, "Reported %d PDOs\n", i);
971  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
972 
973  return STATUS_SUCCESS;
974 }
#define INFO_(ch,...)
Definition: debug.h:159
_In_ PIRP Irp
Definition: csq.h:116
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2143
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Definition: typedefs.h:119
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define ObReferenceObject
Definition: obfuncs.h:204
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:124
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by IntVideoPortDispatchFdoPnp().

◆ IntVideoPortResetDisplayParameters()

static BOOLEAN NTAPI IntVideoPortResetDisplayParameters ( ULONG  Columns,
ULONG  Rows 
)
static

Definition at line 168 of file dispatch.c.

169 {
170  /* Call the extended function, specifying we were called by INBV */
172 }
#define TRUE
Definition: types.h:120
static BOOLEAN NTAPI IntVideoPortResetDisplayParametersEx(_In_ ULONG Columns, _In_ ULONG Rows, _In_ BOOLEAN CalledByInbv)
Definition: dispatch.c:72
_In_ ULONG Rows
Definition: haltypes.h:7
static const COLUMN_LIST Columns[]
Definition: listview.c:19

Referenced by InbvMonitorThread(), and IntVideoPortInbvInitialize().

◆ IntVideoPortResetDisplayParametersEx()

static BOOLEAN NTAPI IntVideoPortResetDisplayParametersEx ( _In_ ULONG  Columns,
_In_ ULONG  Rows,
_In_ BOOLEAN  CalledByInbv 
)
static

Definition at line 72 of file dispatch.c.

76 {
77  BOOLEAN Success = TRUE; // Suppose we don't need to perform a full reset.
78  KIRQL OldIrql;
79  PLIST_ENTRY PrevEntry, Entry;
80  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
82 
83  /* Check if we are at dispatch level or lower, and acquire the lock */
85  if (OldIrql <= DISPATCH_LEVEL)
86  {
87  /* Loop until the lock is free, then raise IRQL to dispatch level */
90  }
92 
93  /* Bail out early if we don't have any resettable adapter */
95  {
96  Success = FALSE; // No adapter found: request HAL to perform a full reset.
97  goto Quit;
98  }
99 
100  /*
101  * If we have been unexpectedly called via a callback from
102  * InbvAcquireDisplayOwnership(), start monitoring INBV.
103  */
104  if (CalledByInbv)
106 
107  for (PrevEntry = &HwResetAdaptersList, Entry = PrevEntry->Flink;
109  PrevEntry = Entry, Entry = Entry->Flink)
110  {
111  /*
112  * Check whether the entry address is properly aligned,
113  * the device and driver extensions must be readable and
114  * the device extension properly back-linked to the last entry.
115  */
116 // #define IS_ALIGNED(addr, align) (((ULONG64)(addr) & (align - 1)) == 0)
117  if (((ULONG_PTR)Entry & (sizeof(ULONG_PTR) - 1)) != 0)
118  {
119  Success = FALSE; // We failed: request HAL to perform a full reset.
120  goto Quit;
121  }
122 
123  DeviceExtension = CONTAINING_RECORD(Entry,
125  HwResetListEntry);
126  /*
127  * As this function can be called as part of the INBV initialization
128  * by the bugcheck code, avoid any problems and protect all accesses
129  * within SEH.
130  */
131  _SEH2_TRY
132  {
133  DriverExtension = DeviceExtension->DriverExtension;
135 
136  if (DeviceExtension->HwResetListEntry.Blink != PrevEntry)
137  {
138  Success = FALSE; // We failed: request HAL to perform a full reset.
139  _SEH2_YIELD(goto Quit);
140  }
141 
142  if ((DeviceExtension->DeviceOpened >= 1) &&
143  (DriverExtension->InitializationData.HwResetHw != NULL))
144  {
145  Success &= DriverExtension->InitializationData.HwResetHw(
146  &DeviceExtension->MiniPortDeviceExtension,
147  Columns, Rows);
148  }
149  }
151  {
152  }
153  _SEH2_END;
154  }
155 
156 Quit:
157  /* Release the lock and restore the old IRQL if we were at dispatch level or lower */
159  if (OldIrql <= DISPATCH_LEVEL)
161 
162  return Success;
163 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
static BOOLEAN InbvMonitoring
Definition: dispatch.c:35
struct _Entry Entry
Definition: kefuncs.h:627
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
#define TRUE
Definition: types.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG Rows
Definition: haltypes.h:7
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:42
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
BOOLEAN FASTCALL KeTestSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:442
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Definition: typedefs.h:119
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
static const COLUMN_LIST Columns[]
Definition: listview.c:19
_SEH2_END
Definition: create.c:4400
LIST_ENTRY HwResetAdaptersList
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
base of all file and directory entries
Definition: entries.h:82

Referenced by IntVideoPortDispatchDeviceControl(), IntVideoPortInbvCleanup(), and IntVideoPortResetDisplayParameters().

◆ IntVideoPortUnload()

VOID NTAPI IntVideoPortUnload ( PDRIVER_OBJECT  DriverObject)

Definition at line 1171 of file dispatch.c.

1172 {
1173 }

Referenced by VideoPortInitialize().

◆ IoctlName()

PSTR IoctlName ( ULONG  Ioctl)

Definition at line 443 of file dispatch.c.

444 {
445  switch (Ioctl)
446  {
448  return "IOCTL_VIDEO_ENABLE_VDM"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x00, METHOD_BUFFERED, FILE_ANY_ACCESS)
450  return "IOCTL_VIDEO_DISABLE_VDM"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x01, METHOD_BUFFERED, FILE_ANY_ACCESS)
452  return "IOCTL_VIDEO_REGISTER_VDM"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x02, METHOD_BUFFERED, FILE_ANY_ACCESS)
454  return "IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x03, METHOD_BUFFERED, FILE_ANY_ACCESS)
456  return "IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x04, METHOD_BUFFERED, FILE_ANY_ACCESS)
458  return "IOCTL_VIDEO_MONITOR_DEVICE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x05, METHOD_BUFFERED, FILE_ANY_ACCESS)
460  return "IOCTL_VIDEO_ENUM_MONITOR_PDO"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x06, METHOD_BUFFERED, FILE_ANY_ACCESS)
462  return "IOCTL_VIDEO_INIT_WIN32K_CALLBACKS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x07, METHOD_BUFFERED, FILE_ANY_ACCESS)
464  return "IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x08, METHOD_BUFFERED, FILE_ANY_ACCESS)
466  return "IOCTL_VIDEO_IS_VGA_DEVICE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x09, METHOD_BUFFERED, FILE_ANY_ACCESS)
468  return "IOCTL_VIDEO_USE_DEVICE_IN_SESSION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x0a, METHOD_BUFFERED, FILE_ANY_ACCESS)
470  return "IOCTL_VIDEO_PREPARE_FOR_EARECOVERY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x0b, METHOD_BUFFERED, FILE_ANY_ACCESS)
472  return "IOCTL_VIDEO_SAVE_HARDWARE_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x80, METHOD_BUFFERED, FILE_ANY_ACCESS)
474  return "IOCTL_VIDEO_RESTORE_HARDWARE_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x81, METHOD_BUFFERED, FILE_ANY_ACCESS)
476  return "IOCTL_VIDEO_QUERY_AVAIL_MODES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x100, METHOD_BUFFERED, FILE_ANY_ACCESS)
478  return "IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x101, METHOD_BUFFERED, FILE_ANY_ACCESS)
480  return "IOCTL_VIDEO_QUERY_CURRENT_MODE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x102, METHOD_BUFFERED, FILE_ANY_ACCESS)
482  return "IOCTL_VIDEO_SET_CURRENT_MODE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x103, METHOD_BUFFERED, FILE_ANY_ACCESS)
484  return "IOCTL_VIDEO_RESET_DEVICE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x104, METHOD_BUFFERED, FILE_ANY_ACCESS)
486  return "IOCTL_VIDEO_LOAD_AND_SET_FONT"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x105, METHOD_BUFFERED, FILE_ANY_ACCESS)
488  return "IOCTL_VIDEO_SET_PALETTE_REGISTERS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x106, METHOD_BUFFERED, FILE_ANY_ACCESS)
490  return "IOCTL_VIDEO_SET_COLOR_REGISTERS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x107, METHOD_BUFFERED, FILE_ANY_ACCESS)
492  return "IOCTL_VIDEO_ENABLE_CURSOR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x108, METHOD_BUFFERED, FILE_ANY_ACCESS)
494  return "IOCTL_VIDEO_DISABLE_CURSOR"; // CTL_CODE (FILE_DEVICE_VIDEO, 0x109, METHOD_BUFFERED, FILE_ANY_ACCESS)
496  return "IOCTL_VIDEO_SET_CURSOR_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10a, METHOD_BUFFERED, FILE_ANY_ACCESS)
498  return "IOCTL_VIDEO_QUERY_CURSOR_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10b, METHOD_BUFFERED, FILE_ANY_ACCESS)
500  return "IOCTL_VIDEO_SET_CURSOR_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10c, METHOD_BUFFERED, FILE_ANY_ACCESS)
502  return "IOCTL_VIDEO_QUERY_CURSOR_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10d, METHOD_BUFFERED, FILE_ANY_ACCESS)
504  return "IOCTL_VIDEO_ENABLE_POINTER"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10e, METHOD_BUFFERED, FILE_ANY_ACCESS)
506  return "IOCTL_VIDEO_DISABLE_POINTER"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10f, METHOD_BUFFERED, FILE_ANY_ACCESS)
508  return "IOCTL_VIDEO_SET_POINTER_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x110, METHOD_BUFFERED, FILE_ANY_ACCESS)
510  return "IOCTL_VIDEO_QUERY_POINTER_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x111, METHOD_BUFFERED, FILE_ANY_ACCESS)
512  return "IOCTL_VIDEO_SET_POINTER_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x112, METHOD_BUFFERED, FILE_ANY_ACCESS)
514  return "IOCTL_VIDEO_QUERY_POINTER_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x113, METHOD_BUFFERED, FILE_ANY_ACCESS)
516  return "IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x114, METHOD_BUFFERED, FILE_ANY_ACCESS)
518  return "IOCTL_VIDEO_GET_BANK_SELECT_CODE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x115, METHOD_BUFFERED, FILE_ANY_ACCESS)
520  return "IOCTL_VIDEO_MAP_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x116, METHOD_BUFFERED, FILE_ANY_ACCESS)
522  return "IOCTL_VIDEO_UNMAP_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x117, METHOD_BUFFERED, FILE_ANY_ACCESS)
524  return "IOCTL_VIDEO_QUERY_PUBLIC_ACCESS_RANGES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x118, METHOD_BUFFERED, FILE_ANY_ACCESS)
526  return "IOCTL_VIDEO_FREE_PUBLIC_ACCESS_RANGES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x119, METHOD_BUFFERED, FILE_ANY_ACCESS)
528  return "IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11a, METHOD_BUFFERED, FILE_ANY_ACCESS)
530  return "IOCTL_VIDEO_SET_POWER_MANAGEMENT"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11b, METHOD_BUFFERED, FILE_ANY_ACCESS)
532  return "IOCTL_VIDEO_GET_POWER_MANAGEMENT"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11c, METHOD_BUFFERED, FILE_ANY_ACCESS)
534  return "IOCTL_VIDEO_SHARE_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11d, METHOD_BUFFERED, FILE_ANY_ACCESS)
536  return "IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11e, METHOD_BUFFERED, FILE_ANY_ACCESS)
538  return "IOCTL_VIDEO_SET_COLOR_LUT_DATA"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11f, METHOD_BUFFERED, FILE_ANY_ACCESS)
540  return "IOCTL_VIDEO_GET_CHILD_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x120, METHOD_BUFFERED, FILE_ANY_ACCESS)
542  return "IOCTL_VIDEO_VALIDATE_CHILD_STATE_CONFIGURATION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x121, METHOD_BUFFERED, FILE_ANY_ACCESS)
544  return "IOCTL_VIDEO_SET_CHILD_STATE_CONFIGURATION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x122, METHOD_BUFFERED, FILE_ANY_ACCESS)
546  return "IOCTL_VIDEO_SWITCH_DUALVIEW"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x123, METHOD_BUFFERED, FILE_ANY_ACCESS)
548  return "IOCTL_VIDEO_SET_BANK_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x124, METHOD_BUFFERED, FILE_ANY_ACCESS)
550  return "IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x125, METHOD_BUFFERED, FILE_ANY_ACCESS)
552  return "IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x126, METHOD_BUFFERED, FILE_ANY_ACCESS)
554  return "IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x127, METHOD_BUFFERED, FILE_ANY_ACCESS)
555  }
556 
557  return "<unknown ioctl code>";
558 }
#define IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES
Definition: ntddvdeo.h:110
#define IOCTL_VIDEO_IS_VGA_DEVICE
Definition: ntddvdeo.h:68
#define IOCTL_VIDEO_QUERY_POINTER_POSITION
Definition: ntddvdeo.h:131
#define IOCTL_VIDEO_QUERY_POINTER_ATTR
Definition: ntddvdeo.h:125
#define IOCTL_VIDEO_SET_POINTER_ATTR
Definition: ntddvdeo.h:164
#define IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY
Definition: ntddvdeo.h:182
#define IOCTL_VIDEO_REGISTER_VDM
Definition: ntddvdeo.h:47
#define IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES
Definition: ntddvdeo.h:128
#define IOCTL_VIDEO_DISABLE_CURSOR
Definition: ntddvdeo.h:77
#define IOCTL_VIDEO_SET_COLOR_LUT_DATA
Definition: ntddvdeo.h:185
#define IOCTL_VIDEO_ENABLE_VDM
Definition: ntddvdeo.h:41
#define IOCTL_VIDEO_SET_CHILD_STATE_CONFIGURATION
Definition: ntddvdeo.h:146
#define IOCTL_VIDEO_GET_POWER_MANAGEMENT
Definition: ntddvdeo.h:98
#define IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS
Definition: ntddvdeo.h:65
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:137
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:104
#define IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:53
#define IOCTL_VIDEO_GET_BANK_SELECT_CODE
Definition: ntddvdeo.h:92
#define IOCTL_VIDEO_DISABLE_POINTER
Definition: ntddvdeo.h:80
#define IOCTL_VIDEO_FREE_PUBLIC_ACCESS_RANGES
Definition: ntddvdeo.h:89
#define IOCTL_VIDEO_ENUM_MONITOR_PDO
Definition: ntddvdeo.h:59
#define IOCTL_VIDEO_QUERY_CURRENT_MODE
Definition: ntddvdeo.h:113
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:152
#define IOCTL_VIDEO_MONITOR_DEVICE
Definition: ntddvdeo.h:56
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:62
#define IOCTL_VIDEO_SET_PALETTE_REGISTERS
Definition: ntddvdeo.h:161
#define IOCTL_VIDEO_SET_CURSOR_POSITION
Definition: ntddvdeo.h:158
#define IOCTL_VIDEO_QUERY_CURSOR_ATTR
Definition: ntddvdeo.h:116
#define IOCTL_VIDEO_SET_POWER_MANAGEMENT
Definition: ntddvdeo.h:170
#define IOCTL_VIDEO_SET_CURSOR_ATTR
Definition: ntddvdeo.h:155
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:179
#define IOCTL_VIDEO_ENABLE_CURSOR
Definition: ntddvdeo.h:83
#define IOCTL_VIDEO_QUERY_CURSOR_POSITION
Definition: ntddvdeo.h:119
#define IOCTL_VIDEO_SWITCH_DUALVIEW
Definition: ntddvdeo.h:176
#define IOCTL_VIDEO_PREPARE_FOR_EARECOVERY
Definition: ntddvdeo.h:74
#define IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:200
#define IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS
Definition: ntddvdeo.h:194
#define IOCTL_VIDEO_LOAD_AND_SET_FONT
Definition: ntddvdeo.h:101
#define IOCTL_VIDEO_DISABLE_VDM
Definition: ntddvdeo.h:44
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:122
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:107
#define IOCTL_VIDEO_SHARE_VIDEO_MEMORY
Definition: ntddvdeo.h:173
#define IOCTL_VIDEO_VALIDATE_CHILD_STATE_CONFIGURATION
Definition: ntddvdeo.h:188
#define IOCTL_VIDEO_GET_CHILD_STATE
Definition: ntddvdeo.h:95
#define IOCTL_VIDEO_ENABLE_POINTER
Definition: ntddvdeo.h:86
#define IOCTL_VIDEO_QUERY_PUBLIC_ACCESS_RANGES
Definition: ntddvdeo.h:134
#define IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:197
#define IOCTL_VIDEO_RESTORE_HARDWARE_STATE
Definition: ntddvdeo.h:140
#define IOCTL_VIDEO_USE_DEVICE_IN_SESSION
Definition: ntddvdeo.h:71
#define IOCTL_VIDEO_SAVE_HARDWARE_STATE
Definition: ntddvdeo.h:143
#define IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:50
#define IOCTL_VIDEO_SET_POINTER_POSITION
Definition: ntddvdeo.h:167
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:149
#define IOCTL_VIDEO_SET_BANK_POSITION
Definition: ntddvdeo.h:191

Referenced by IntVideoPortDispatchDeviceControl().

◆ VideoPortForwardDeviceControl()

static NTSTATUS VideoPortForwardDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 647 of file dispatch.c.

650 {
651  PIO_STACK_LOCATION IrpStack;
653  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
655 
656  TRACE_(VIDEOPRT, "VideoPortForwardDeviceControl\n");
657 
658  IrpStack = IoGetCurrentIrpStackLocation(Irp);
659  DeviceExtension = DeviceObject->DeviceExtension;
660  DriverExtension = DeviceExtension->DriverExtension;
661 
662  /* Translate the IRP to a VRP */
663  vrp.StatusBlock = (PSTATUS_BLOCK)&Irp->IoStatus;
664  vrp.IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
665 
666  INFO_(VIDEOPRT, "- IoControlCode: %x\n", vrp.IoControlCode);
667 
668  /* We're assuming METHOD_BUFFERED */
669  vrp.InputBuffer = Irp->AssociatedIrp.SystemBuffer;
670  vrp.InputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
671  vrp.OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
672  vrp.OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
673 
674  /* Call the Miniport Driver with the VRP */
675  DriverExtension->InitializationData.HwStartIO(&DeviceExtension->MiniPortDeviceExtension,
676  &vrp);
677 
678  INFO_(VIDEOPRT, "- Returned status: %x\n", Irp->IoStatus.Status);
679 
680  /* Map from win32 error codes to NT status values. */
681  switch (Irp->IoStatus.Status)
682  {
683  case NO_ERROR:
684  return STATUS_SUCCESS;
687  case ERROR_MORE_DATA:
688  return STATUS_BUFFER_OVERFLOW;
690  return STATUS_NOT_IMPLEMENTED;
695  case ERROR_DEV_NOT_EXIST:
697  case ERROR_IO_PENDING:
698  return STATUS_PENDING;
699  default:
700  return STATUS_UNSUCCESSFUL;
701  }
702 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define INFO_(ch,...)
Definition: debug.h:159
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _STATUS_BLOCK * PSTATUS_BLOCK
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
ULONG InputBufferLength
Definition: video.h:333
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define NO_ERROR
Definition: dderror.h:5
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
ULONG OutputBufferLength
Definition: video.h:335
#define TRACE_(x)
Definition: compat.h:76
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
#define ERROR_MORE_DATA
Definition: dderror.h:13
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
PSTATUS_BLOCK StatusBlock
Definition: video.h:331
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by IntVideoPortDispatchDeviceControl().

◆ VideoPortInitWin32kCallbacks()

static NTSTATUS VideoPortInitWin32kCallbacks ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PVIDEO_WIN32K_CALLBACKS  Win32kCallbacks,
_In_ ULONG  BufferLength,
_Out_ PULONG_PTR  Information 
)
static

Definition at line 620 of file dispatch.c.

625 {
627  if (BufferLength < sizeof(VIDEO_WIN32K_CALLBACKS))
628  {
629  ERR_(VIDEOPRT, "Buffer too small for VIDEO_WIN32K_CALLBACKS: %lx\n",
630  BufferLength);
632  }
633 
634  /* Save the callout function globally */
635  Win32kCallout = Win32kCallbacks->Callout;
636 
637  /* Return reasonable values to Win32k */
638  Win32kCallbacks->bACPI = FALSE;
639  Win32kCallbacks->pPhysDeviceObject = DeviceObject;
640  Win32kCallbacks->DualviewFlags = 0;
641 
642  return STATUS_SUCCESS;
643 }
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG BufferLength
Definition: cdrom.h:989
#define ERR_(ch,...)
Definition: debug.h:156
Iosb Information
Definition: create.c:4353
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define FALSE
Definition: types.h:117
struct _VIDEO_WIN32K_CALLBACKS VIDEO_WIN32K_CALLBACKS
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
return STATUS_SUCCESS
Definition: btrfs.c:3014
static PVIDEO_WIN32K_CALLOUT Win32kCallout
Definition: dispatch.c:33

Referenced by IntVideoPortDispatchDeviceControl().

◆ VideoPortUseDeviceInSession()

static NTSTATUS VideoPortUseDeviceInSession ( _Inout_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PVIDEO_DEVICE_SESSION_STATUS  SessionState,
_In_ ULONG  BufferLength,
_Out_ PULONG_PTR  Information 
)
static

Definition at line 562 of file dispatch.c.

567 {
568  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
569 
570  /* Check buffer size */
573  {
574  ERR_(VIDEOPRT, "Buffer too small for VIDEO_DEVICE_SESSION_STATUS: %lx\n",
575  BufferLength);
577  }
578 
579  /* Get the device extension */
580  DeviceExtension = DeviceObject->DeviceExtension;
581 
582  /* Shall we enable the session? */
583  if (SessionState->bEnable)
584  {
585  /* Check if we have no session yet */
586  if (DeviceExtension->SessionId == -1)
587  {
588  /* Use this session and return success */
589  DeviceExtension->SessionId = PsGetCurrentProcessSessionId();
590  SessionState->bSuccess = TRUE;
591  }
592  else
593  {
594  ERR_(VIDEOPRT, "Requested to set session, but session is already set to: 0x%lx\n",
595  DeviceExtension->SessionId);
596  SessionState->bSuccess = FALSE;
597  }
598  }
599  else
600  {
601  /* Check if we belong to the current session */
602  if (DeviceExtension->SessionId == PsGetCurrentProcessSessionId())
603  {
604  /* Reset the session and return success */
605  DeviceExtension->SessionId = -1;
606  SessionState->bSuccess = TRUE;
607  }
608  else
609  {
610  ERR_(VIDEOPRT, "Requested to reset session, but session is not set\n");
611  SessionState->bSuccess = FALSE;
612  }
613  }
614 
615  return STATUS_SUCCESS;
616 }
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG BufferLength
Definition: cdrom.h:989
#define TRUE
Definition: types.h:120
struct _VIDEO_DEVICE_SESSION_STATUS VIDEO_DEVICE_SESSION_STATUS
#define ERR_(ch,...)
Definition: debug.h:156
Iosb Information
Definition: create.c:4353
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define FALSE
Definition: types.h:117
ULONG NTAPI PsGetCurrentProcessSessionId(VOID)
Definition: process.c:1133
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by IntVideoPortDispatchDeviceControl().

◆ VideoPortWin32kCallout()

static VOID VideoPortWin32kCallout ( _In_ PVIDEO_WIN32K_CALLBACKS_PARAMS  CallbackParams)
static

Definition at line 40 of file dispatch.c.

42 {
43  if (!Win32kCallout)
44  return;
45 
46  /* Perform the call in the context of CSRSS */
47  if (!CsrProcess)
48  return;
49 
51  Win32kCallout(CallbackParams);
53 }
PKPROCESS CsrProcess
Definition: videoprt.c:39
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:618
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:579
static PVIDEO_WIN32K_CALLOUT Win32kCallout
Definition: dispatch.c:33

Referenced by InbvMonitorThread().

Variable Documentation

◆ InbvMonitoring

BOOLEAN InbvMonitoring = FALSE
static

Definition at line 35 of file dispatch.c.

Referenced by InbvMonitorThread(), and IntVideoPortResetDisplayParametersEx().

◆ InbvThreadHandle

HANDLE InbvThreadHandle = NULL
static

Definition at line 34 of file dispatch.c.

Referenced by IntVideoPortInbvCleanup(), and IntVideoPortInbvInitialize().

◆ Win32kCallout

PVIDEO_WIN32K_CALLOUT Win32kCallout = NULL
static

Definition at line 33 of file dispatch.c.

Referenced by VideoPortInitWin32kCallbacks(), and VideoPortWin32kCallout().