ReactOS 0.4.16-dev-1225-g1286711
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 VideoPortEnumMonitorPdo (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_MONITOR_DEVICE *ppMonitorDevices, _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
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}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
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 KeGetCurrentThread
Definition: hal.h:55
VOID NTAPI InbvNotifyDisplayOwnershipLost(_In_ INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:407
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:319
#define LOW_REALTIME_PRIORITY
#define KernelMode
Definition: asm.h:38
@ VideoFindAdapterCallout
Definition: ntddvdeo.h:296
unsigned short USHORT
Definition: pedump.c:61
VIDEO_WIN32K_CALLBACKS_PARAMS_TYPE CalloutType
Definition: ntddvdeo.h:319
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1300
int64_t LONGLONG
Definition: typedefs.h:68
LONGLONG QuadPart
Definition: typedefs.h:114
static BOOLEAN InbvMonitoring
Definition: dispatch.c:35
static VOID VideoPortWin32kCallout(_In_ PVIDEO_WIN32K_CALLBACKS_PARAMS CallbackParams)
Definition: dispatch.c:40
static BOOLEAN NTAPI IntVideoPortResetDisplayParameters(ULONG Columns, ULONG Rows)
Definition: dispatch.c:168

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 DriverExtension->InitializationData.StartingDeviceNumber,
350 0,
351 &DeviceObject);
352 if (!NT_SUCCESS(Status))
353 {
354 ERR_(VIDEOPRT, "IntVideoPortCreateAdapterDeviceObject() failed with status 0x%lx\n", Status);
355 }
356 return Status;
357}
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1916
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define ERR_(ch,...)
Definition: debug.h:156
NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject(_In_ PDRIVER_OBJECT DriverObject, _In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject, _In_ USHORT AdapterNumber, _In_ USHORT DisplayNumber, _Out_opt_ PDEVICE_OBJECT *DeviceObject)
Definition: videoprt.c:159
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchCleanup()

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

Definition at line 1170 of file dispatch.c.

1173{
1174 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1175
1176 DeviceExtension = DeviceObject->DeviceExtension;
1177 RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
1178
1179 Irp->IoStatus.Status = STATUS_SUCCESS;
1180 Irp->IoStatus.Information = 0;
1182
1183 return STATUS_SUCCESS;
1184}
_In_ PIRP Irp
Definition: csq.h:116
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_SUCCESS
Definition: shellext.h:65
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ IntVideoPortDispatchClose()

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

Definition at line 436 of file dispatch.c.

439{
440 TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
441
443
444 Irp->IoStatus.Status = STATUS_SUCCESS;
446 return STATUS_SUCCESS;
447}
#define TRACE_(x)
Definition: compat.h:76
static NTSTATUS IntVideoPortInbvCleanup(IN PDEVICE_OBJECT DeviceObject)
Definition: dispatch.c:300

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchDeviceControl()

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

Definition at line 768 of file dispatch.c.

771{
772 PIO_STACK_LOCATION IrpStack;
775
776 TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
777
779
780 switch (IrpStack->MajorFunction)
781 {
783 /* This is the main part of this function and is handled below */
784 break;
785
786 case IRP_MJ_SHUTDOWN:
787 {
788 /* Dereference CSRSS */
789 PKPROCESS OldCsrProcess;
790 OldCsrProcess = InterlockedExchangePointer((PVOID*)&CsrProcess, NULL);
791 if (OldCsrProcess)
792 ObDereferenceObject(OldCsrProcess);
793
794 Irp->IoStatus.Status = STATUS_SUCCESS;
796 return STATUS_SUCCESS;
797 }
798
799 default:
800 ERR_(VIDEOPRT, "- Unknown MajorFunction 0x%x\n", IrpStack->MajorFunction);
801 Irp->IoStatus.Status = STATUS_SUCCESS;
803 return STATUS_SUCCESS;
804 }
805
806 IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
807
808 INFO_(VIDEOPRT, "- IoControlCode: 0x%x: %s\n", IoControlCode, IoctlName(IoControlCode));
809
810 switch (IoControlCode)
811 {
815 WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_VDM are UNIMPLEMENTED!\n");
817 break;
818
821 WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_OUTPUT_DEVICE_POWER_STATE are UNIMPLEMENTED!\n");
823 break;
824
827 WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_POWER_MANAGEMENT are UNIMPLEMENTED!\n");
829 break;
830
834 WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_BRIGHTNESS are UNIMPLEMENTED!\n");
836 break;
837
839 INFO_(VIDEOPRT, "- IOCTL_VIDEO_ENUM_MONITOR_PDO\n");
841 Irp->AssociatedIrp.SystemBuffer,
842 &Irp->IoStatus.Information);
843 break;
844
846 INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
848 Irp->AssociatedIrp.SystemBuffer,
849 IrpStack->Parameters.DeviceIoControl.InputBufferLength,
850 &Irp->IoStatus.Information);
851 break;
852
854 WARN_(VIDEOPRT, "- IOCTL_VIDEO_IS_VGA_DEVICE is UNIMPLEMENTED!\n");
856 break;
857
859 INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
861 Irp->AssociatedIrp.SystemBuffer,
862 IrpStack->Parameters.DeviceIoControl.InputBufferLength,
863 &Irp->IoStatus.Information);
864 break;
865
867 INFO_(VIDEOPRT, "- IOCTL_VIDEO_PREPARE_FOR_EARECOVERY\n");
868 /*
869 * The Win32k Watchdog Timer detected that a thread spent more time
870 * in a display driver than the allotted time its threshold specified,
871 * and thus is going to attempt to recover by switching to VGA mode.
872 * If this attempt fails, the watchdog generates bugcheck 0xEA
873 * "THREAD_STUCK_IN_DEVICE_DRIVER".
874 *
875 * Prepare the recovery by resetting the display adapters to
876 * standard VGA 80x25 text mode.
877 */
880 break;
881
882 default:
883 /* Forward to the Miniport Driver */
885 break;
886 }
887
888 INFO_(VIDEOPRT, "- Returned status: 0x%x\n", Status);
889
890 Irp->IoStatus.Status = Status;
892 return Status;
893}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define NULL
Definition: types.h:112
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define IOCTL_VIDEO_SET_POWER_MANAGEMENT
Definition: ntddvdeo.h:239
#define IOCTL_VIDEO_IS_VGA_DEVICE
Definition: ntddvdeo.h:137
#define IOCTL_VIDEO_ENABLE_VDM
Definition: ntddvdeo.h:110
#define IOCTL_VIDEO_USE_DEVICE_IN_SESSION
Definition: ntddvdeo.h:140
#define IOCTL_VIDEO_GET_POWER_MANAGEMENT
Definition: ntddvdeo.h:167
#define IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:266
#define IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:269
#define IOCTL_VIDEO_PREPARE_FOR_EARECOVERY
Definition: ntddvdeo.h:143
#define IOCTL_VIDEO_DISABLE_VDM
Definition: ntddvdeo.h:113
#define IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:122
#define IOCTL_VIDEO_REGISTER_VDM
Definition: ntddvdeo.h:116
#define IOCTL_VIDEO_ENUM_MONITOR_PDO
Definition: ntddvdeo.h:128
#define IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:119
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:131
#define IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS
Definition: ntddvdeo.h:263
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define INFO_(ch,...)
Definition: debug.h:159
#define WARN_(ch,...)
Definition: debug.h:157
union _IO_STACK_LOCATION::@1629 Parameters
struct _IO_STACK_LOCATION::@1629::@1630 DeviceIoControl
uint32_t ULONG
Definition: typedefs.h:59
PKPROCESS CsrProcess
Definition: videoprt.c:39
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
static BOOLEAN NTAPI IntVideoPortResetDisplayParametersEx(_In_ ULONG Columns, _In_ ULONG Rows, _In_ BOOLEAN CalledByInbv)
Definition: dispatch.c:72
static NTSTATUS VideoPortEnumMonitorPdo(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_MONITOR_DEVICE *ppMonitorDevices, _Out_ PULONG_PTR Information)
Definition: dispatch.c:627
PSTR IoctlName(ULONG Ioctl)
Definition: dispatch.c:450
static NTSTATUS VideoPortForwardDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:701
static NTSTATUS VideoPortUseDeviceInSession(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:569
static NTSTATUS VideoPortInitWin32kCallbacks(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:672
#define IRP_MJ_SHUTDOWN
#define IO_VIDEO_INCREMENT
Definition: iotypes.h:609
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchFdoPnp()

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

Definition at line 1079 of file dispatch.c.

1082{
1085 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1086
1088
1089 switch (IrpSp->MinorFunction)
1090 {
1093 if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
1095 Irp->IoStatus.Status = Status;
1096 Irp->IoStatus.Information = 0;
1098 break;
1099
1101 /* Call lower drivers, and ignore result (that's probably STATUS_NOT_SUPPORTED) */
1103 /* Now, fill resource requirements list */
1105 Irp->IoStatus.Status = Status;
1107 break;
1108
1111 {
1113 Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1114 }
1115 else
1116 {
1118 Irp->IoStatus.Status = Status;
1120 }
1121 break;
1122
1127
1128 case IRP_MN_STOP_DEVICE:
1130 if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
1132 Irp->IoStatus.Status = Status;
1133 Irp->IoStatus.Information = 0;
1135 break;
1136
1140 Irp->IoStatus.Status = STATUS_SUCCESS;
1141 Irp->IoStatus.Information = 0;
1143 break;
1144
1145 default:
1146 Status = Irp->IoStatus.Status;
1148 break;
1149 }
1150
1151 return Status;
1152}
#define VOID
Definition: acefi.h:82
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4138
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1225
struct _IO_STACK_LOCATION::@4119::@4144 QueryDeviceRelations
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
NTSTATUS NTAPI IntVideoPortForwardIrpAndWait(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatch.c:1051
NTSTATUS NTAPI IntVideoPortQueryBusRelations(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatch.c:991
NTSTATUS NTAPI IntVideoPortPnPStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:897
NTSTATUS NTAPI IntVideoPortFilterResourceRequirements(IN PDEVICE_OBJECT DeviceObject, IN PIO_STACK_LOCATION IrpStack, IN PIRP Irp)
Definition: resource.c:87
#define IRP_MN_CANCEL_STOP_DEVICE
@ BusRelations
Definition: iotypes.h:2152
#define IRP_MN_START_DEVICE
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

Referenced by IntVideoPortDispatchPnp().

◆ IntVideoPortDispatchOpen()

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

Definition at line 369 of file dispatch.c.

372{
374 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
376
377 TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n");
378
379 if (!CsrProcess)
380 {
381 /*
382 * We know the first open call will be from the CSRSS process
383 * to let us know its handle.
384 */
385 INFO_(VIDEOPRT, "Referencing CSRSS\n");
388 INFO_(VIDEOPRT, "CsrProcess 0x%p\n", CsrProcess);
389
391 if (!NT_SUCCESS(Status))
392 {
393 ERR_(VIDEOPRT, "IntInitializeVideoAddressSpace() failed: 0x%lx\n", Status);
396 return Status;
397 }
398 }
399
400 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
401 DriverExtension = DeviceExtension->DriverExtension;
402
403 // FIXME: (Re-)initialize INBV only if DeviceObject doesn't belong to a mirror driver.
405
406 if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
407 {
409 InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
410
411 /* Query children, now that device is opened */
413 }
414 else
415 {
417 }
418
419 Irp->IoStatus.Status = Status;
420 Irp->IoStatus.Information = FILE_OPENED;
422
423 return Status;
424}
#define InterlockedIncrement
Definition: armddk.h:53
NTSTATUS NTAPI IntInitializeVideoAddressSpace(VOID)
Definition: int10.c:200
#define FILE_OPENED
Definition: nt_native.h:769
VPAPI VP_STATUS NTAPI VideoPortEnumerateChildren(IN PVOID HwDeviceExtension, IN PVOID Reserved)
Definition: videoprt.c:1448
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:113
int32_t * PLONG
Definition: typedefs.h:58
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:201
static NTSTATUS IntVideoPortInbvInitialize(VOID)
Definition: dispatch.c:274
#define ObReferenceObject
Definition: obfuncs.h:204
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPnp()

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

Definition at line 1156 of file dispatch.c.

1159{
1160 PVIDEO_PORT_COMMON_EXTENSION CommonExtension = DeviceObject->DeviceExtension;
1161
1162 if (CommonExtension->Fdo)
1164 else
1166}
NTSTATUS NTAPI IntVideoPortDispatchPdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: child.c:404
NTSTATUS NTAPI IntVideoPortDispatchFdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1079

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPower()

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

Definition at line 1188 of file dispatch.c.

1191{
1193 NTSTATUS Status = Irp->IoStatus.Status;
1194 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1195
1197
1198 if (DeviceExtension->Common.Fdo)
1199 {
1202 return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1203 }
1204 else
1205 {
1206 switch (IrpSp->MinorFunction)
1207 {
1208 case IRP_MN_QUERY_POWER:
1209 case IRP_MN_SET_POWER:
1211 break;
1212 }
1214 Irp->IoStatus.Status = Status;
1216 return Status;
1217 }
1218}
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
#define IRP_MN_SET_POWER
#define IRP_MN_QUERY_POWER

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchSystemControl()

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

Definition at line 1222 of file dispatch.c.

1225{
1227 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1228
1229 if (DeviceExtension->Common.Fdo)
1230 {
1232 return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1233 }
1234 else
1235 {
1236 Status = Irp->IoStatus.Status;
1238 return Status;
1239 }
1240}

Referenced by VideoPortInitialize().

◆ IntVideoPortForwardIrpAndWait()

NTSTATUS NTAPI IntVideoPortForwardIrpAndWait ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 1051 of file dispatch.c.

1052{
1053 KEVENT Event;
1055 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension =
1057
1062 &Event,
1063 TRUE,
1064 TRUE,
1065 TRUE);
1066
1067 Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1068 if (Status == STATUS_PENDING)
1069 {
1071 Status = Irp->IoStatus.Status;
1072 }
1073
1074 return Status;
1075}
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
@ NotificationEvent
#define IoCopyCurrentIrpStackLocationToNext(Irp)
Definition: ntifs_ex.h:413
NTSTATUS NTAPI IntVideoPortForwardIrpAndWaitCompletionRoutine(PDEVICE_OBJECT Fdo, PIRP Irp, PVOID Context)
Definition: dispatch.c:976
@ Executive
Definition: ketypes.h:415

Referenced by IntVideoPortDispatchFdoPnp().

◆ IntVideoPortForwardIrpAndWaitCompletionRoutine()

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

Definition at line 976 of file dispatch.c.

980{
982
983 if (Irp->PendingReturned)
985
987}
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68

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}
#define InterlockedDecrement
Definition: armddk.h:52
if(dx< 0)
Definition: linetemp.h:194
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
static HANDLE InbvThreadHandle
Definition: dispatch.c:34

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:36
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#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
static VOID NTAPI InbvMonitorThread(_In_ PVOID Context)
Definition: dispatch.c:208

Referenced by IntVideoPortDispatchOpen().

◆ IntVideoPortPnPStartDevice()

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

Definition at line 897 of file dispatch.c.

900{
904 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
906
907 /* Get the initialization data we saved in VideoPortInitialize.*/
908 DriverObject = DeviceObject->DriverObject;
910 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
911
912 /* Store some resources in the DeviceExtension. */
913 AllocatedResources = Stack->Parameters.StartDevice.AllocatedResources;
915 {
919 ULONG ResourceListSize;
920
921 /* Save the resource list */
922 ResourceCount = AllocatedResources->List[0].PartialResourceList.Count;
923 ResourceListSize =
924 FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
925 PartialDescriptors[ResourceCount]);
926 DeviceExtension->AllocatedResources = ExAllocatePool(PagedPool, ResourceListSize);
927 if (DeviceExtension->AllocatedResources == NULL)
928 {
930 }
931
932 RtlCopyMemory(DeviceExtension->AllocatedResources,
934 ResourceListSize);
935
936 /* Get the interrupt level/vector - needed by HwFindAdapter sometimes */
937 FullList = AllocatedResources->List;
938 ASSERT(AllocatedResources->Count == 1);
939 INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
940 FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber, FullList->PartialResourceList.Version, FullList->PartialResourceList.Revision);
941
942 /* FIXME: Is this ASSERT ok for resources from the PNP manager? */
943 ASSERT(FullList->InterfaceType == PCIBus);
944 ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
945 ASSERT(1 == FullList->PartialResourceList.Version);
946 ASSERT(1 == FullList->PartialResourceList.Revision);
948 Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
949 Descriptor++)
950 {
952 {
953 DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
954 DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
955 if (Descriptor->ShareDisposition == CmResourceShareShared)
956 DeviceExtension->InterruptShared = TRUE;
957 else
958 DeviceExtension->InterruptShared = FALSE;
959 }
960 }
961 }
962
963 INFO_(VIDEOPRT, "Interrupt level: 0x%x Interrupt Vector: 0x%x\n",
964 DeviceExtension->InterruptLevel,
965 DeviceExtension->InterruptVector);
966
967 /* Create adapter device object. */
971}
#define PagedPool
Definition: env_spec_w32.h:308
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
@ PCIBus
Definition: hwresource.cpp:142
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
static ULONG ResourceCount
Definition: inbv.c:50
#define ASSERT(a)
Definition: mode.c:44
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4643
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
PCM_RESOURCE_LIST AllocatedResources
Definition: videoprt.h:94
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS NTAPI IntVideoPortFindAdapter(IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT DeviceObject)
Definition: videoprt.c:414
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
@ CmResourceShareShared
Definition: cmtypes.h:243

Referenced by IntVideoPortDispatchFdoPnp().

◆ IntVideoPortQueryBusRelations()

NTSTATUS NTAPI IntVideoPortQueryBusRelations ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 991 of file dispatch.c.

992{
993 PDEVICE_RELATIONS DeviceRelations;
994 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
995 PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
996 ULONG i;
997 PLIST_ENTRY CurrentEntry;
999
1000 if (InterlockedCompareExchange((PLONG)&DeviceExtension->DeviceOpened, 0, 0) == 0)
1001 {
1002 /* Device not opened. Don't enumerate children yet */
1003 WARN_(VIDEOPRT, "Skipping child enumeration because device is not opened");
1005 }
1006 /* Query children of the device. */
1008 if (!NT_SUCCESS(Status))
1009 return Status;
1010
1011 /* Count the children */
1012 i = 0;
1013 CurrentEntry = DeviceExtension->ChildDeviceList.Flink;
1014 while (CurrentEntry != &DeviceExtension->ChildDeviceList)
1015 {
1016 i++;
1017 CurrentEntry = CurrentEntry->Flink;
1018 }
1019
1020 if (i == 0)
1021 return Irp->IoStatus.Status;
1022
1023 DeviceRelations = ExAllocatePool(PagedPool,
1024 sizeof(DEVICE_RELATIONS) + ((i - 1) * sizeof(PVOID)));
1025 if (!DeviceRelations) return STATUS_NO_MEMORY;
1026
1027 DeviceRelations->Count = i;
1028
1029 /* Add the children */
1030 i = 0;
1031 CurrentEntry = DeviceExtension->ChildDeviceList.Flink;
1032 while (CurrentEntry != &DeviceExtension->ChildDeviceList)
1033 {
1034 ChildExtension = CONTAINING_RECORD(CurrentEntry, VIDEO_PORT_CHILD_EXTENSION, ListEntry);
1035
1036 ObReferenceObject(ChildExtension->PhysicalDeviceObject);
1037 DeviceRelations->Objects[i] = ChildExtension->PhysicalDeviceObject;
1038
1039 i++;
1040 CurrentEntry = CurrentEntry->Flink;
1041 }
1042
1043 INFO_(VIDEOPRT, "Reported %d PDOs\n", i);
1044 Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
1045
1046 return STATUS_SUCCESS;
1047}
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define InterlockedCompareExchange
Definition: interlocked.h:119
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:127
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
NTSTATUS NTAPI IntVideoPortEnumerateChildren(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: videoprt.c:1284

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}
static const COLUMN_LIST Columns[]
Definition: listview.c:19
_In_ ULONG Rows
Definition: haltypes.h:7

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.
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 */
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 */
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
156Quit:
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}
unsigned char BOOLEAN
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
@ Success
Definition: eventcreate.c:712
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
BOOLEAN FASTCALL KeTestSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:475
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
Definition: ke.h:125
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
Definition: ke.h:135
base of all file and directory entries
Definition: entries.h:83
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
uint32_t ULONG_PTR
Definition: typedefs.h:65
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:43
LIST_ENTRY HwResetAdaptersList
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

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

◆ IntVideoPortUnload()

VOID NTAPI IntVideoPortUnload ( PDRIVER_OBJECT  DriverObject)

Definition at line 1244 of file dispatch.c.

1245{
1246}

Referenced by VideoPortInitialize().

◆ IoctlName()

PSTR IoctlName ( ULONG  Ioctl)

Definition at line 450 of file dispatch.c.

451{
452 switch (Ioctl)
453 {
455 return "IOCTL_VIDEO_ENABLE_VDM"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x00, METHOD_BUFFERED, FILE_ANY_ACCESS)
457 return "IOCTL_VIDEO_DISABLE_VDM"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x01, METHOD_BUFFERED, FILE_ANY_ACCESS)
459 return "IOCTL_VIDEO_REGISTER_VDM"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x02, METHOD_BUFFERED, FILE_ANY_ACCESS)
461 return "IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x03, METHOD_BUFFERED, FILE_ANY_ACCESS)
463 return "IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x04, METHOD_BUFFERED, FILE_ANY_ACCESS)
465 return "IOCTL_VIDEO_MONITOR_DEVICE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x05, METHOD_BUFFERED, FILE_ANY_ACCESS)
467 return "IOCTL_VIDEO_ENUM_MONITOR_PDO"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x06, METHOD_BUFFERED, FILE_ANY_ACCESS)
469 return "IOCTL_VIDEO_INIT_WIN32K_CALLBACKS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x07, METHOD_BUFFERED, FILE_ANY_ACCESS)
471 return "IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x08, METHOD_BUFFERED, FILE_ANY_ACCESS)
473 return "IOCTL_VIDEO_IS_VGA_DEVICE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x09, METHOD_BUFFERED, FILE_ANY_ACCESS)
475 return "IOCTL_VIDEO_USE_DEVICE_IN_SESSION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x0a, METHOD_BUFFERED, FILE_ANY_ACCESS)
477 return "IOCTL_VIDEO_PREPARE_FOR_EARECOVERY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x0b, METHOD_BUFFERED, FILE_ANY_ACCESS)
479 return "IOCTL_VIDEO_SAVE_HARDWARE_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x80, METHOD_BUFFERED, FILE_ANY_ACCESS)
481 return "IOCTL_VIDEO_RESTORE_HARDWARE_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x81, METHOD_BUFFERED, FILE_ANY_ACCESS)
483 return "IOCTL_VIDEO_QUERY_AVAIL_MODES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x100, METHOD_BUFFERED, FILE_ANY_ACCESS)
485 return "IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x101, METHOD_BUFFERED, FILE_ANY_ACCESS)
487 return "IOCTL_VIDEO_QUERY_CURRENT_MODE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x102, METHOD_BUFFERED, FILE_ANY_ACCESS)
489 return "IOCTL_VIDEO_SET_CURRENT_MODE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x103, METHOD_BUFFERED, FILE_ANY_ACCESS)
491 return "IOCTL_VIDEO_RESET_DEVICE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x104, METHOD_BUFFERED, FILE_ANY_ACCESS)
493 return "IOCTL_VIDEO_LOAD_AND_SET_FONT"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x105, METHOD_BUFFERED, FILE_ANY_ACCESS)
495 return "IOCTL_VIDEO_SET_PALETTE_REGISTERS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x106, METHOD_BUFFERED, FILE_ANY_ACCESS)
497 return "IOCTL_VIDEO_SET_COLOR_REGISTERS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x107, METHOD_BUFFERED, FILE_ANY_ACCESS)
499 return "IOCTL_VIDEO_ENABLE_CURSOR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x108, METHOD_BUFFERED, FILE_ANY_ACCESS)
501 return "IOCTL_VIDEO_DISABLE_CURSOR"; // CTL_CODE (FILE_DEVICE_VIDEO, 0x109, METHOD_BUFFERED, FILE_ANY_ACCESS)
503 return "IOCTL_VIDEO_SET_CURSOR_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10a, METHOD_BUFFERED, FILE_ANY_ACCESS)
505 return "IOCTL_VIDEO_QUERY_CURSOR_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10b, METHOD_BUFFERED, FILE_ANY_ACCESS)
507 return "IOCTL_VIDEO_SET_CURSOR_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10c, METHOD_BUFFERED, FILE_ANY_ACCESS)
509 return "IOCTL_VIDEO_QUERY_CURSOR_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10d, METHOD_BUFFERED, FILE_ANY_ACCESS)
511 return "IOCTL_VIDEO_ENABLE_POINTER"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10e, METHOD_BUFFERED, FILE_ANY_ACCESS)
513 return "IOCTL_VIDEO_DISABLE_POINTER"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10f, METHOD_BUFFERED, FILE_ANY_ACCESS)
515 return "IOCTL_VIDEO_SET_POINTER_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x110, METHOD_BUFFERED, FILE_ANY_ACCESS)
517 return "IOCTL_VIDEO_QUERY_POINTER_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x111, METHOD_BUFFERED, FILE_ANY_ACCESS)
519 return "IOCTL_VIDEO_SET_POINTER_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x112, METHOD_BUFFERED, FILE_ANY_ACCESS)
521 return "IOCTL_VIDEO_QUERY_POINTER_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x113, METHOD_BUFFERED, FILE_ANY_ACCESS)
523 return "IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x114, METHOD_BUFFERED, FILE_ANY_ACCESS)
525 return "IOCTL_VIDEO_GET_BANK_SELECT_CODE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x115, METHOD_BUFFERED, FILE_ANY_ACCESS)
527 return "IOCTL_VIDEO_MAP_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x116, METHOD_BUFFERED, FILE_ANY_ACCESS)
529 return "IOCTL_VIDEO_UNMAP_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x117, METHOD_BUFFERED, FILE_ANY_ACCESS)
531 return "IOCTL_VIDEO_QUERY_PUBLIC_ACCESS_RANGES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x118, METHOD_BUFFERED, FILE_ANY_ACCESS)
533 return "IOCTL_VIDEO_FREE_PUBLIC_ACCESS_RANGES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x119, METHOD_BUFFERED, FILE_ANY_ACCESS)
535 return "IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11a, METHOD_BUFFERED, FILE_ANY_ACCESS)
537 return "IOCTL_VIDEO_SET_POWER_MANAGEMENT"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11b, METHOD_BUFFERED, FILE_ANY_ACCESS)
539 return "IOCTL_VIDEO_GET_POWER_MANAGEMENT"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11c, METHOD_BUFFERED, FILE_ANY_ACCESS)
541 return "IOCTL_VIDEO_SHARE_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11d, METHOD_BUFFERED, FILE_ANY_ACCESS)
543 return "IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11e, METHOD_BUFFERED, FILE_ANY_ACCESS)
545 return "IOCTL_VIDEO_SET_COLOR_LUT_DATA"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11f, METHOD_BUFFERED, FILE_ANY_ACCESS)
547 return "IOCTL_VIDEO_GET_CHILD_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x120, METHOD_BUFFERED, FILE_ANY_ACCESS)
549 return "IOCTL_VIDEO_VALIDATE_CHILD_STATE_CONFIGURATION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x121, METHOD_BUFFERED, FILE_ANY_ACCESS)
551 return "IOCTL_VIDEO_SET_CHILD_STATE_CONFIGURATION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x122, METHOD_BUFFERED, FILE_ANY_ACCESS)
553 return "IOCTL_VIDEO_SWITCH_DUALVIEW"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x123, METHOD_BUFFERED, FILE_ANY_ACCESS)
555 return "IOCTL_VIDEO_SET_BANK_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x124, METHOD_BUFFERED, FILE_ANY_ACCESS)
557 return "IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x125, METHOD_BUFFERED, FILE_ANY_ACCESS)
559 return "IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x126, METHOD_BUFFERED, FILE_ANY_ACCESS)
561 return "IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x127, METHOD_BUFFERED, FILE_ANY_ACCESS)
562 }
563
564 return "<unknown ioctl code>";
565}
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in ULONG Ioctl
#define IOCTL_VIDEO_SWITCH_DUALVIEW
Definition: ntddvdeo.h:245
#define IOCTL_VIDEO_SHARE_VIDEO_MEMORY
Definition: ntddvdeo.h:242
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:173
#define IOCTL_VIDEO_ENABLE_POINTER
Definition: ntddvdeo.h:155
#define IOCTL_VIDEO_SET_PALETTE_REGISTERS
Definition: ntddvdeo.h:230
#define IOCTL_VIDEO_SET_POINTER_ATTR
Definition: ntddvdeo.h:233
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:248
#define IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS
Definition: ntddvdeo.h:134
#define IOCTL_VIDEO_QUERY_CURSOR_ATTR
Definition: ntddvdeo.h:185
#define IOCTL_VIDEO_QUERY_CURSOR_POSITION
Definition: ntddvdeo.h:188
#define IOCTL_VIDEO_SET_CURSOR_POSITION
Definition: ntddvdeo.h:227
#define IOCTL_VIDEO_QUERY_CURRENT_MODE
Definition: ntddvdeo.h:182
#define IOCTL_VIDEO_SET_BANK_POSITION
Definition: ntddvdeo.h:260
#define IOCTL_VIDEO_MONITOR_DEVICE
Definition: ntddvdeo.h:125
#define IOCTL_VIDEO_ENABLE_CURSOR
Definition: ntddvdeo.h:152
#define IOCTL_VIDEO_DISABLE_CURSOR
Definition: ntddvdeo.h:146
#define IOCTL_VIDEO_GET_CHILD_STATE
Definition: ntddvdeo.h:164
#define IOCTL_VIDEO_SET_POINTER_POSITION
Definition: ntddvdeo.h:236
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:221
#define IOCTL_VIDEO_FREE_PUBLIC_ACCESS_RANGES
Definition: ntddvdeo.h:158
#define IOCTL_VIDEO_GET_BANK_SELECT_CODE
Definition: ntddvdeo.h:161
#define IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES
Definition: ntddvdeo.h:197
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:218
#define IOCTL_VIDEO_VALIDATE_CHILD_STATE_CONFIGURATION
Definition: ntddvdeo.h:257
#define IOCTL_VIDEO_SET_COLOR_LUT_DATA
Definition: ntddvdeo.h:254
#define IOCTL_VIDEO_LOAD_AND_SET_FONT
Definition: ntddvdeo.h:170
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:206
#define IOCTL_VIDEO_QUERY_POINTER_POSITION
Definition: ntddvdeo.h:200
#define IOCTL_VIDEO_SET_CURSOR_ATTR
Definition: ntddvdeo.h:224
#define IOCTL_VIDEO_SET_CHILD_STATE_CONFIGURATION
Definition: ntddvdeo.h:215
#define IOCTL_VIDEO_DISABLE_POINTER
Definition: ntddvdeo.h:149
#define IOCTL_VIDEO_QUERY_POINTER_ATTR
Definition: ntddvdeo.h:194
#define IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY
Definition: ntddvdeo.h:251
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:176
#define IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES
Definition: ntddvdeo.h:179
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:191
#define IOCTL_VIDEO_SAVE_HARDWARE_STATE
Definition: ntddvdeo.h:212
#define IOCTL_VIDEO_RESTORE_HARDWARE_STATE
Definition: ntddvdeo.h:209
#define IOCTL_VIDEO_QUERY_PUBLIC_ACCESS_RANGES
Definition: ntddvdeo.h:203

Referenced by IntVideoPortDispatchDeviceControl().

◆ VideoPortEnumMonitorPdo()

static NTSTATUS VideoPortEnumMonitorPdo ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PVIDEO_MONITOR_DEVICE ppMonitorDevices,
_Out_ PULONG_PTR  Information 
)
static

Definition at line 627 of file dispatch.c.

631{
632 PVIDEO_MONITOR_DEVICE pMonitorDevices;
633 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
634 PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
635 ULONG i;
636 PLIST_ENTRY CurrentEntry;
637
638 /* Count the children */
639 i = 0;
640 CurrentEntry = DeviceExtension->ChildDeviceList.Flink;
641 while (CurrentEntry != &DeviceExtension->ChildDeviceList)
642 {
643 i++;
644 CurrentEntry = CurrentEntry->Flink;
645 }
646
647 pMonitorDevices = ExAllocatePoolZero(PagedPool,
648 sizeof(VIDEO_MONITOR_DEVICE) * (i + 1),
650 if (!pMonitorDevices)
652
653 /* Add the children */
654 i = 0;
655 CurrentEntry = DeviceExtension->ChildDeviceList.Flink;
656 while (CurrentEntry != &DeviceExtension->ChildDeviceList)
657 {
658 ChildExtension = CONTAINING_RECORD(CurrentEntry, VIDEO_PORT_CHILD_EXTENSION, ListEntry);
659
661 pMonitorDevices[i++].pdo = ChildExtension->PhysicalDeviceObject;
662 CurrentEntry = CurrentEntry->Flink;
663 }
664
665 *ppMonitorDevices = pMonitorDevices;
666 *Information = sizeof(pMonitorDevices);
667 return STATUS_SUCCESS;
668}
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

Referenced by IntVideoPortDispatchDeviceControl().

◆ VideoPortForwardDeviceControl()

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

Definition at line 701 of file dispatch.c.

704{
705 PIO_STACK_LOCATION IrpStack;
707 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
709
710 TRACE_(VIDEOPRT, "VideoPortForwardDeviceControl\n");
711
713 DeviceExtension = DeviceObject->DeviceExtension;
714 DriverExtension = DeviceExtension->DriverExtension;
715
716 /* Translate the IRP to a VRP */
717 vrp.StatusBlock = (PSTATUS_BLOCK)&Irp->IoStatus;
718 vrp.IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
719
720 INFO_(VIDEOPRT, "- IoControlCode: %x\n", vrp.IoControlCode);
721
722 /* We're assuming METHOD_BUFFERED */
723 vrp.InputBuffer = Irp->AssociatedIrp.SystemBuffer;
724 vrp.InputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
725 vrp.OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
726 vrp.OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
727
728 /* Call the Miniport Driver with the VRP */
729 DriverExtension->InitializationData.HwStartIO(&DeviceExtension->MiniPortDeviceExtension,
730 &vrp);
731
732 INFO_(VIDEOPRT, "- Returned status: %x\n", Irp->IoStatus.Status);
733
734 /* Map from win32 error codes to NT status values. */
735 switch (Irp->IoStatus.Status)
736 {
737 case NO_ERROR:
738 return STATUS_SUCCESS;
741 case ERROR_MORE_DATA:
751 case ERROR_IO_PENDING:
752 return STATUS_PENDING;
753 default:
754 return STATUS_UNSUCCESSFUL;
755 }
756}
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
struct _STATUS_BLOCK * PSTATUS_BLOCK
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
ULONG InputBufferLength
Definition: video.h:333
PSTATUS_BLOCK StatusBlock
Definition: video.h:331
ULONG OutputBufferLength
Definition: video.h:335
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

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 672 of file dispatch.c.

677{
678 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
679
682 {
683 ERR_(VIDEOPRT, "Buffer too small for VIDEO_WIN32K_CALLBACKS: %lx\n",
686 }
687
688 /* Save the callout function globally */
689 Win32kCallout = Win32kCallbacks->Callout;
690
691 /* Return reasonable values to Win32k */
692 Win32kCallbacks->bACPI = FALSE;
693 Win32kCallbacks->pPhysDeviceObject = DeviceExtension->PhysicalDeviceObject;
694 Win32kCallbacks->DualviewFlags = 0;
695
696 return STATUS_SUCCESS;
697}
struct _VIDEO_WIN32K_CALLBACKS VIDEO_WIN32K_CALLBACKS
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
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 569 of file dispatch.c.

574{
575 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
576
577 /* Check buffer size */
580 {
581 ERR_(VIDEOPRT, "Buffer too small for VIDEO_DEVICE_SESSION_STATUS: %lx\n",
584 }
585
586 /* Get the device extension */
587 DeviceExtension = DeviceObject->DeviceExtension;
588
589 /* Shall we enable the session? */
590 if (SessionState->bEnable)
591 {
592 /* Check if we have no session yet */
593 if (DeviceExtension->SessionId == -1)
594 {
595 /* Use this session and return success */
596 DeviceExtension->SessionId = PsGetCurrentProcessSessionId();
597 SessionState->bSuccess = TRUE;
598 }
599 else
600 {
601 ERR_(VIDEOPRT, "Requested to set session, but session is already set to: 0x%lx\n",
602 DeviceExtension->SessionId);
603 SessionState->bSuccess = FALSE;
604 }
605 }
606 else
607 {
608 /* Check if we belong to the current session */
609 if (DeviceExtension->SessionId == PsGetCurrentProcessSessionId())
610 {
611 /* Reset the session and return success */
612 DeviceExtension->SessionId = -1;
613 SessionState->bSuccess = TRUE;
614 }
615 else
616 {
617 ERR_(VIDEOPRT, "Requested to reset session, but session is not set\n");
618 SessionState->bSuccess = FALSE;
619 }
620 }
621
622 return STATUS_SUCCESS;
623}
struct _VIDEO_DEVICE_SESSION_STATUS VIDEO_DEVICE_SESSION_STATUS
ULONG NTAPI PsGetCurrentProcessSessionId(VOID)
Definition: process.c:1133

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}
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:621
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:582

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().