ReactOS  0.4.15-dev-3446-g30010a5
dispatch.c
Go to the documentation of this file.
1 /*
2  * VideoPort driver
3  *
4  * Copyright (C) 2002, 2003, 2004 ReactOS Team
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  */
21 
22 #include "videoprt.h"
23 
24 #include <ndk/inbvfuncs.h>
25 #include <ndk/obfuncs.h>
26 #include <ndk/psfuncs.h>
27 
28 #define NDEBUG
29 #include <debug.h>
30 
31 /* GLOBAL VARIABLES ***********************************************************/
32 
36 
37 /* PRIVATE FUNCTIONS **********************************************************/
38 
39 static VOID
41  _In_ PVIDEO_WIN32K_CALLBACKS_PARAMS CallbackParams)
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 }
54 
55 /*
56  * Reinitialize the display to base VGA mode.
57  *
58  * Returns TRUE if it completely resets the adapter to the given character mode.
59  * Returns FALSE otherwise, indicating that the HAL should perform the VGA mode
60  * reset itself after HwVidResetHw() returns control.
61  *
62  * This callback has been registered with InbvNotifyDisplayOwnershipLost()
63  * and is called by InbvAcquireDisplayOwnership(), typically when the bugcheck
64  * code regains display access. Therefore this routine can be called at any
65  * IRQL, and in particular at IRQL = HIGH_LEVEL. This routine must also reside
66  * completely in non-paged pool, and cannot perform the following actions:
67  * Allocate memory, access pageable memory, use any synchronization mechanisms
68  * or call any routine that must execute at IRQL = DISPATCH_LEVEL or below.
69  */
70 static BOOLEAN
71 NTAPI
74  _In_ ULONG Rows,
75  _In_ BOOLEAN CalledByInbv)
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 }
164 
165 /* This callback is registered with InbvNotifyDisplayOwnershipLost() */
166 static BOOLEAN
167 NTAPI
169 {
170  /* Call the extended function, specifying we were called by INBV */
172 }
173 
174 /*
175  * (Adapted for ReactOS/Win2k3 from an original comment
176  * by Gé van Geldorp, June 2003, r4937)
177  *
178  * DISPLAY OWNERSHIP
179  *
180  * So, who owns the physical display and is allowed to write to it?
181  *
182  * In NT 5.x (Win2k/Win2k3), upon boot INBV/BootVid owns the display, unless
183  * /NOGUIBOOT has been specified in the boot command line. Later in the boot
184  * sequence, WIN32K.SYS opens the DISPLAY device. This open call ends up in
185  * VIDEOPRT.SYS. This component takes ownership of the display by calling
186  * InbvNotifyDisplayOwnershipLost() -- effectively telling INBV to release
187  * ownership of the display it previously had. From that moment on, the display
188  * is owned by that component and can be switched to graphics mode. The display
189  * is not supposed to return to text mode, except in case of a bugcheck.
190  * The bugcheck code calls InbvAcquireDisplayOwnership() so as to make INBV
191  * re-take display ownership, and calls back the function previously registered
192  * by VIDEOPRT.SYS with InbvNotifyDisplayOwnershipLost(). After the bugcheck,
193  * execution is halted. So, under NT, the only possible sequence of display
194  * modes is text mode -> graphics mode -> text mode (the latter hopefully
195  * happening very infrequently).
196  *
197  * In ReactOS things are a little bit different. We want to have a functional
198  * interactive text mode. We should be able to switch back and forth from
199  * text mode to graphics mode when a GUI app is started and then finished.
200  * Also, when the system bugchecks in graphics mode we want to switch back to
201  * text mode and show the bugcheck information. Last but not least, when using
202  * KDBG in /DEBUGPORT=SCREEN mode, breaking into the debugger would trigger a
203  * switch to text mode, and the user would expect that by continuing execution
204  * a switch back to graphics mode is done.
205  */
206 static VOID
207 NTAPI
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 }
272 
273 static NTSTATUS
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 }
298 
299 static NTSTATUS
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 }
330 
331 
332 NTSTATUS
333 NTAPI
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 }
358 
359 /*
360  * IntVideoPortDispatchOpen
361  *
362  * Answer requests for Open calls.
363  *
364  * Run Level
365  * PASSIVE_LEVEL
366  */
367 NTSTATUS
368 NTAPI
371  IN PIRP Irp)
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);
395  CsrProcess = NULL;
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  else
412  {
414  }
415 
416  Irp->IoStatus.Status = Status;
417  Irp->IoStatus.Information = FILE_OPENED;
419 
420  return Status;
421 }
422 
423 /*
424  * IntVideoPortDispatchClose
425  *
426  * Answer requests for Close calls.
427  *
428  * Run Level
429  * PASSIVE_LEVEL
430  */
431 NTSTATUS
432 NTAPI
435  IN PIRP Irp)
436 {
437  TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
438 
440 
441  Irp->IoStatus.Status = STATUS_SUCCESS;
443  return STATUS_SUCCESS;
444 }
445 
446 PSTR
448 {
449  switch (Ioctl)
450  {
452  return "IOCTL_VIDEO_ENABLE_VDM"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x00, METHOD_BUFFERED, FILE_ANY_ACCESS)
454  return "IOCTL_VIDEO_DISABLE_VDM"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x01, METHOD_BUFFERED, FILE_ANY_ACCESS)
456  return "IOCTL_VIDEO_REGISTER_VDM"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x02, METHOD_BUFFERED, FILE_ANY_ACCESS)
458  return "IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x03, METHOD_BUFFERED, FILE_ANY_ACCESS)
460  return "IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x04, METHOD_BUFFERED, FILE_ANY_ACCESS)
462  return "IOCTL_VIDEO_MONITOR_DEVICE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x05, METHOD_BUFFERED, FILE_ANY_ACCESS)
464  return "IOCTL_VIDEO_ENUM_MONITOR_PDO"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x06, METHOD_BUFFERED, FILE_ANY_ACCESS)
466  return "IOCTL_VIDEO_INIT_WIN32K_CALLBACKS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x07, METHOD_BUFFERED, FILE_ANY_ACCESS)
468  return "IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x08, METHOD_BUFFERED, FILE_ANY_ACCESS)
470  return "IOCTL_VIDEO_IS_VGA_DEVICE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x09, METHOD_BUFFERED, FILE_ANY_ACCESS)
472  return "IOCTL_VIDEO_USE_DEVICE_IN_SESSION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x0a, METHOD_BUFFERED, FILE_ANY_ACCESS)
474  return "IOCTL_VIDEO_PREPARE_FOR_EARECOVERY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x0b, METHOD_BUFFERED, FILE_ANY_ACCESS)
476  return "IOCTL_VIDEO_SAVE_HARDWARE_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x80, METHOD_BUFFERED, FILE_ANY_ACCESS)
478  return "IOCTL_VIDEO_RESTORE_HARDWARE_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x81, METHOD_BUFFERED, FILE_ANY_ACCESS)
480  return "IOCTL_VIDEO_QUERY_AVAIL_MODES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x100, METHOD_BUFFERED, FILE_ANY_ACCESS)
482  return "IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x101, METHOD_BUFFERED, FILE_ANY_ACCESS)
484  return "IOCTL_VIDEO_QUERY_CURRENT_MODE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x102, METHOD_BUFFERED, FILE_ANY_ACCESS)
486  return "IOCTL_VIDEO_SET_CURRENT_MODE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x103, METHOD_BUFFERED, FILE_ANY_ACCESS)
488  return "IOCTL_VIDEO_RESET_DEVICE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x104, METHOD_BUFFERED, FILE_ANY_ACCESS)
490  return "IOCTL_VIDEO_LOAD_AND_SET_FONT"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x105, METHOD_BUFFERED, FILE_ANY_ACCESS)
492  return "IOCTL_VIDEO_SET_PALETTE_REGISTERS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x106, METHOD_BUFFERED, FILE_ANY_ACCESS)
494  return "IOCTL_VIDEO_SET_COLOR_REGISTERS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x107, METHOD_BUFFERED, FILE_ANY_ACCESS)
496  return "IOCTL_VIDEO_ENABLE_CURSOR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x108, METHOD_BUFFERED, FILE_ANY_ACCESS)
498  return "IOCTL_VIDEO_DISABLE_CURSOR"; // CTL_CODE (FILE_DEVICE_VIDEO, 0x109, METHOD_BUFFERED, FILE_ANY_ACCESS)
500  return "IOCTL_VIDEO_SET_CURSOR_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10a, METHOD_BUFFERED, FILE_ANY_ACCESS)
502  return "IOCTL_VIDEO_QUERY_CURSOR_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10b, METHOD_BUFFERED, FILE_ANY_ACCESS)
504  return "IOCTL_VIDEO_SET_CURSOR_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10c, METHOD_BUFFERED, FILE_ANY_ACCESS)
506  return "IOCTL_VIDEO_QUERY_CURSOR_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10d, METHOD_BUFFERED, FILE_ANY_ACCESS)
508  return "IOCTL_VIDEO_ENABLE_POINTER"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10e, METHOD_BUFFERED, FILE_ANY_ACCESS)
510  return "IOCTL_VIDEO_DISABLE_POINTER"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x10f, METHOD_BUFFERED, FILE_ANY_ACCESS)
512  return "IOCTL_VIDEO_SET_POINTER_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x110, METHOD_BUFFERED, FILE_ANY_ACCESS)
514  return "IOCTL_VIDEO_QUERY_POINTER_ATTR"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x111, METHOD_BUFFERED, FILE_ANY_ACCESS)
516  return "IOCTL_VIDEO_SET_POINTER_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x112, METHOD_BUFFERED, FILE_ANY_ACCESS)
518  return "IOCTL_VIDEO_QUERY_POINTER_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x113, METHOD_BUFFERED, FILE_ANY_ACCESS)
520  return "IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x114, METHOD_BUFFERED, FILE_ANY_ACCESS)
522  return "IOCTL_VIDEO_GET_BANK_SELECT_CODE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x115, METHOD_BUFFERED, FILE_ANY_ACCESS)
524  return "IOCTL_VIDEO_MAP_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x116, METHOD_BUFFERED, FILE_ANY_ACCESS)
526  return "IOCTL_VIDEO_UNMAP_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x117, METHOD_BUFFERED, FILE_ANY_ACCESS)
528  return "IOCTL_VIDEO_QUERY_PUBLIC_ACCESS_RANGES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x118, METHOD_BUFFERED, FILE_ANY_ACCESS)
530  return "IOCTL_VIDEO_FREE_PUBLIC_ACCESS_RANGES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x119, METHOD_BUFFERED, FILE_ANY_ACCESS)
532  return "IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11a, METHOD_BUFFERED, FILE_ANY_ACCESS)
534  return "IOCTL_VIDEO_SET_POWER_MANAGEMENT"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11b, METHOD_BUFFERED, FILE_ANY_ACCESS)
536  return "IOCTL_VIDEO_GET_POWER_MANAGEMENT"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11c, METHOD_BUFFERED, FILE_ANY_ACCESS)
538  return "IOCTL_VIDEO_SHARE_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11d, METHOD_BUFFERED, FILE_ANY_ACCESS)
540  return "IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11e, METHOD_BUFFERED, FILE_ANY_ACCESS)
542  return "IOCTL_VIDEO_SET_COLOR_LUT_DATA"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x11f, METHOD_BUFFERED, FILE_ANY_ACCESS)
544  return "IOCTL_VIDEO_GET_CHILD_STATE"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x120, METHOD_BUFFERED, FILE_ANY_ACCESS)
546  return "IOCTL_VIDEO_VALIDATE_CHILD_STATE_CONFIGURATION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x121, METHOD_BUFFERED, FILE_ANY_ACCESS)
548  return "IOCTL_VIDEO_SET_CHILD_STATE_CONFIGURATION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x122, METHOD_BUFFERED, FILE_ANY_ACCESS)
550  return "IOCTL_VIDEO_SWITCH_DUALVIEW"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x123, METHOD_BUFFERED, FILE_ANY_ACCESS)
552  return "IOCTL_VIDEO_SET_BANK_POSITION"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x124, METHOD_BUFFERED, FILE_ANY_ACCESS)
554  return "IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x125, METHOD_BUFFERED, FILE_ANY_ACCESS)
556  return "IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x126, METHOD_BUFFERED, FILE_ANY_ACCESS)
558  return "IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS"; // CTL_CODE(FILE_DEVICE_VIDEO, 0x127, METHOD_BUFFERED, FILE_ANY_ACCESS)
559  }
560 
561  return "<unknown ioctl code>";
562 }
563 
564 static
565 NTSTATUS
571 {
572  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
573 
574  /* Check buffer size */
577  {
578  ERR_(VIDEOPRT, "Buffer too small for VIDEO_DEVICE_SESSION_STATUS: %lx\n",
579  BufferLength);
581  }
582 
583  /* Get the device extension */
584  DeviceExtension = DeviceObject->DeviceExtension;
585 
586  /* Shall we enable the session? */
587  if (SessionState->bEnable)
588  {
589  /* Check if we have no session yet */
590  if (DeviceExtension->SessionId == -1)
591  {
592  /* Use this session and return success */
593  DeviceExtension->SessionId = PsGetCurrentProcessSessionId();
594  SessionState->bSuccess = TRUE;
595  }
596  else
597  {
598  ERR_(VIDEOPRT, "Requested to set session, but session is already set to: 0x%lx\n",
599  DeviceExtension->SessionId);
600  SessionState->bSuccess = FALSE;
601  }
602  }
603  else
604  {
605  /* Check if we belong to the current session */
606  if (DeviceExtension->SessionId == PsGetCurrentProcessSessionId())
607  {
608  /* Reset the session and return success */
609  DeviceExtension->SessionId = -1;
610  SessionState->bSuccess = TRUE;
611  }
612  else
613  {
614  ERR_(VIDEOPRT, "Requested to reset session, but session is not set\n");
615  SessionState->bSuccess = FALSE;
616  }
617  }
618 
619  return STATUS_SUCCESS;
620 }
621 
622 static
623 NTSTATUS
626  _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks,
629 {
631  if (BufferLength < sizeof(VIDEO_WIN32K_CALLBACKS))
632  {
633  ERR_(VIDEOPRT, "Buffer too small for VIDEO_WIN32K_CALLBACKS: %lx\n",
634  BufferLength);
636  }
637 
638  /* Save the callout function globally */
639  Win32kCallout = Win32kCallbacks->Callout;
640 
641  /* Return reasonable values to Win32k */
642  Win32kCallbacks->bACPI = FALSE;
643  Win32kCallbacks->pPhysDeviceObject = DeviceObject;
644  Win32kCallbacks->DualviewFlags = 0;
645 
646  return STATUS_SUCCESS;
647 }
648 
649 static
650 NTSTATUS
653  IN PIRP Irp)
654 {
655  PIO_STACK_LOCATION IrpStack;
657  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
659 
660  TRACE_(VIDEOPRT, "VideoPortForwardDeviceControl\n");
661 
662  IrpStack = IoGetCurrentIrpStackLocation(Irp);
663  DeviceExtension = DeviceObject->DeviceExtension;
664  DriverExtension = DeviceExtension->DriverExtension;
665 
666  /* Translate the IRP to a VRP */
667  vrp.StatusBlock = (PSTATUS_BLOCK)&Irp->IoStatus;
668  vrp.IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
669 
670  INFO_(VIDEOPRT, "- IoControlCode: %x\n", vrp.IoControlCode);
671 
672  /* We're assuming METHOD_BUFFERED */
673  vrp.InputBuffer = Irp->AssociatedIrp.SystemBuffer;
674  vrp.InputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
675  vrp.OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
676  vrp.OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
677 
678  /* Call the Miniport Driver with the VRP */
679  DriverExtension->InitializationData.HwStartIO(&DeviceExtension->MiniPortDeviceExtension,
680  &vrp);
681 
682  INFO_(VIDEOPRT, "- Returned status: %x\n", Irp->IoStatus.Status);
683 
684  /* Map from win32 error codes to NT status values. */
685  switch (Irp->IoStatus.Status)
686  {
687  case NO_ERROR:
688  return STATUS_SUCCESS;
691  case ERROR_MORE_DATA:
692  return STATUS_BUFFER_OVERFLOW;
694  return STATUS_NOT_IMPLEMENTED;
699  case ERROR_DEV_NOT_EXIST:
701  case ERROR_IO_PENDING:
702  return STATUS_PENDING;
703  default:
704  return STATUS_UNSUCCESSFUL;
705  }
706 }
707 
708 /*
709  * IntVideoPortDispatchDeviceControl
710  *
711  * Answer requests for device control calls.
712  *
713  * Run Level
714  * PASSIVE_LEVEL
715  */
716 NTSTATUS
717 NTAPI
720  IN PIRP Irp)
721 {
722  PIO_STACK_LOCATION IrpStack;
725 
726  TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
727 
728  IrpStack = IoGetCurrentIrpStackLocation(Irp);
729 
730  switch (IrpStack->MajorFunction)
731  {
733  /* This is the main part of this function and is handled below */
734  break;
735 
736  case IRP_MJ_SHUTDOWN:
737  {
738  /* Dereference CSRSS */
739  PKPROCESS OldCsrProcess;
740  OldCsrProcess = InterlockedExchangePointer((PVOID*)&CsrProcess, NULL);
741  if (OldCsrProcess)
742  ObDereferenceObject(OldCsrProcess);
743 
744  Irp->IoStatus.Status = STATUS_SUCCESS;
746  return STATUS_SUCCESS;
747  }
748 
749  default:
750  ERR_(VIDEOPRT, "- Unknown MajorFunction 0x%x\n", IrpStack->MajorFunction);
751  Irp->IoStatus.Status = STATUS_SUCCESS;
753  return STATUS_SUCCESS;
754  }
755 
756  IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
757 
758  INFO_(VIDEOPRT, "- IoControlCode: 0x%x: %s\n", IoControlCode, IoctlName(IoControlCode));
759 
760  switch (IoControlCode)
761  {
765  WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_VDM are UNIMPLEMENTED!\n");
767  break;
768 
771  WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_OUTPUT_DEVICE_POWER_STATE are UNIMPLEMENTED!\n");
773  break;
774 
777  WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_POWER_MANAGEMENT are UNIMPLEMENTED!\n");
779  break;
780 
784  WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_BRIGHTNESS are UNIMPLEMENTED!\n");
786  break;
787 
789  INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
791  Irp->AssociatedIrp.SystemBuffer,
792  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
793  &Irp->IoStatus.Information);
794  break;
795 
797  WARN_(VIDEOPRT, "- IOCTL_VIDEO_IS_VGA_DEVICE is UNIMPLEMENTED!\n");
799  break;
800 
802  INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
804  Irp->AssociatedIrp.SystemBuffer,
805  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
806  &Irp->IoStatus.Information);
807  break;
808 
810  INFO_(VIDEOPRT, "- IOCTL_VIDEO_PREPARE_FOR_EARECOVERY\n");
811  /*
812  * The Win32k Watchdog Timer detected that a thread spent more time
813  * in a display driver than the allotted time its threshold specified,
814  * and thus is going to attempt to recover by switching to VGA mode.
815  * If this attempt fails, the watchdog generates bugcheck 0xEA
816  * "THREAD_STUCK_IN_DEVICE_DRIVER".
817  *
818  * Prepare the recovery by resetting the display adapters to
819  * standard VGA 80x25 text mode.
820  */
823  break;
824 
825  default:
826  /* Forward to the Miniport Driver */
828  break;
829  }
830 
831  INFO_(VIDEOPRT, "- Returned status: 0x%x\n", Status);
832 
833  Irp->IoStatus.Status = Status;
835  return Status;
836 }
837 
838 NTSTATUS
839 NTAPI
842  IN PIRP Irp)
843 {
847  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
849 
850  /* Get the initialization data we saved in VideoPortInitialize.*/
851  DriverObject = DeviceObject->DriverObject;
853  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
854 
855  /* Store some resources in the DeviceExtension. */
856  AllocatedResources = Stack->Parameters.StartDevice.AllocatedResources;
858  {
859  CM_FULL_RESOURCE_DESCRIPTOR *FullList;
862  ULONG ResourceListSize;
863 
864  /* Save the resource list */
865  ResourceCount = AllocatedResources->List[0].PartialResourceList.Count;
866  ResourceListSize =
867  FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
868  PartialDescriptors[ResourceCount]);
869  DeviceExtension->AllocatedResources = ExAllocatePool(PagedPool, ResourceListSize);
870  if (DeviceExtension->AllocatedResources == NULL)
871  {
873  }
874 
875  RtlCopyMemory(DeviceExtension->AllocatedResources,
877  ResourceListSize);
878 
879  /* Get the interrupt level/vector - needed by HwFindAdapter sometimes */
880  FullList = AllocatedResources->List;
881  ASSERT(AllocatedResources->Count == 1);
882  INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
883  FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber, FullList->PartialResourceList.Version, FullList->PartialResourceList.Revision);
884 
885  /* FIXME: Is this ASSERT ok for resources from the PNP manager? */
886  ASSERT(FullList->InterfaceType == PCIBus);
887  ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
888  ASSERT(1 == FullList->PartialResourceList.Version);
889  ASSERT(1 == FullList->PartialResourceList.Revision);
891  Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
892  Descriptor++)
893  {
894  if (Descriptor->Type == CmResourceTypeInterrupt)
895  {
896  DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
897  DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
898  if (Descriptor->ShareDisposition == CmResourceShareShared)
899  DeviceExtension->InterruptShared = TRUE;
900  else
901  DeviceExtension->InterruptShared = FALSE;
902  }
903  }
904  }
905 
906  INFO_(VIDEOPRT, "Interrupt level: 0x%x Interrupt Vector: 0x%x\n",
907  DeviceExtension->InterruptLevel,
908  DeviceExtension->InterruptVector);
909 
910  /* Create adapter device object. */
913  DeviceObject);
914 }
915 
916 
917 NTSTATUS
918 NTAPI
921  PIRP Irp,
922  PVOID Context)
923 {
925 
926  if (Irp->PendingReturned)
928 
930 }
931 
932 NTSTATUS
933 NTAPI
935 {
936  PDEVICE_RELATIONS DeviceRelations;
937  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
938  PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
939  ULONG i;
940  PLIST_ENTRY CurrentEntry;
941 
942  /* Count the children */
943  i = 0;
944  CurrentEntry = DeviceExtension->ChildDeviceList.Flink;
945  while (CurrentEntry != &DeviceExtension->ChildDeviceList)
946  {
947  i++;
948  CurrentEntry = CurrentEntry->Flink;
949  }
950 
951  if (i == 0)
952  return Irp->IoStatus.Status;
953 
954  DeviceRelations = ExAllocatePool(PagedPool,
955  sizeof(DEVICE_RELATIONS) + ((i - 1) * sizeof(PVOID)));
956  if (!DeviceRelations) return STATUS_NO_MEMORY;
957 
958  DeviceRelations->Count = i;
959 
960  /* Add the children */
961  i = 0;
962  CurrentEntry = DeviceExtension->ChildDeviceList.Flink;
963  while (CurrentEntry != &DeviceExtension->ChildDeviceList)
964  {
965  ChildExtension = CONTAINING_RECORD(CurrentEntry, VIDEO_PORT_CHILD_EXTENSION, ListEntry);
966 
967  ObReferenceObject(ChildExtension->PhysicalDeviceObject);
968  DeviceRelations->Objects[i] = ChildExtension->PhysicalDeviceObject;
969 
970  i++;
971  CurrentEntry = CurrentEntry->Flink;
972  }
973 
974  INFO_(VIDEOPRT, "Reported %d PDOs\n", i);
975  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
976 
977  return STATUS_SUCCESS;
978 }
979 
980 NTSTATUS
981 NTAPI
983 {
984  KEVENT Event;
986  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension =
987  (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
988 
993  &Event,
994  TRUE,
995  TRUE,
996  TRUE);
997 
998  Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
999  if (Status == STATUS_PENDING)
1000  {
1002  Status = Irp->IoStatus.Status;
1003  }
1004 
1005  return Status;
1006 }
1007 
1008 NTSTATUS
1009 NTAPI
1012  IN PIRP Irp)
1013 {
1015  NTSTATUS Status;
1016  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1017 
1019 
1020  switch (IrpSp->MinorFunction)
1021  {
1022  case IRP_MN_START_DEVICE:
1024  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
1026  Irp->IoStatus.Status = Status;
1027  Irp->IoStatus.Information = 0;
1029  break;
1030 
1032  /* Call lower drivers, and ignore result (that's probably STATUS_NOT_SUPPORTED) */
1034  /* Now, fill resource requirements list */
1036  Irp->IoStatus.Status = Status;
1038  break;
1039 
1041  if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
1042  {
1044  Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1045  }
1046  else
1047  {
1049  Irp->IoStatus.Status = Status;
1051  }
1052  break;
1053 
1054  case IRP_MN_REMOVE_DEVICE:
1058 
1059  case IRP_MN_STOP_DEVICE:
1061  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
1063  Irp->IoStatus.Status = Status;
1064  Irp->IoStatus.Information = 0;
1066  break;
1067 
1071  Irp->IoStatus.Status = STATUS_SUCCESS;
1072  Irp->IoStatus.Information = 0;
1074  break;
1075 
1076  default:
1077  Status = Irp->IoStatus.Status;
1079  break;
1080  }
1081 
1082  return Status;
1083 }
1084 
1085 NTSTATUS
1086 NTAPI
1089  IN PIRP Irp)
1090 {
1091  PVIDEO_PORT_COMMON_EXTENSION CommonExtension = DeviceObject->DeviceExtension;
1092 
1093  if (CommonExtension->Fdo)
1095  else
1097 }
1098 
1099 NTSTATUS
1100 NTAPI
1103  IN PIRP Irp)
1104 {
1105  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1106 
1107  DeviceExtension = DeviceObject->DeviceExtension;
1108  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
1109 
1110  Irp->IoStatus.Status = STATUS_SUCCESS;
1111  Irp->IoStatus.Information = 0;
1113 
1114  return STATUS_SUCCESS;
1115 }
1116 
1117 NTSTATUS
1118 NTAPI
1121  IN PIRP Irp)
1122 {
1124  NTSTATUS Status = Irp->IoStatus.Status;
1125  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1126 
1128 
1129  if (DeviceExtension->Common.Fdo)
1130  {
1133  return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1134  }
1135  else
1136  {
1137  switch (IrpSp->MinorFunction)
1138  {
1139  case IRP_MN_QUERY_POWER:
1140  case IRP_MN_SET_POWER:
1142  break;
1143  }
1145  Irp->IoStatus.Status = Status;
1147  return Status;
1148  }
1149 }
1150 
1151 NTSTATUS
1152 NTAPI
1155  IN PIRP Irp)
1156 {
1157  NTSTATUS Status;
1158  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1159 
1160  if (DeviceExtension->Common.Fdo)
1161  {
1163  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1164  }
1165  else
1166  {
1167  Status = Irp->IoStatus.Status;
1169  return Status;
1170  }
1171 }
1172 
1173 VOID
1174 NTAPI
1176 {
1177 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
NTSTATUS NTAPI IntVideoPortFindAdapter(IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT DeviceObject)
Definition: videoprt.c:341
#define IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES
Definition: ntddvdeo.h:110
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define IRP_MN_CANCEL_REMOVE_DEVICE
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
#define IOCTL_VIDEO_IS_VGA_DEVICE
Definition: ntddvdeo.h:68
NTSTATUS NTAPI IntVideoPortDispatchPdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: child.c:386
VOID NTAPI InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:638
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
static NTSTATUS VideoPortUseDeviceInSession(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:566
NTSTATUS NTAPI IntVideoPortDispatchPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1119
#define IOCTL_VIDEO_QUERY_POINTER_POSITION
Definition: ntddvdeo.h:131
#define IRP_MN_REMOVE_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IOCTL_VIDEO_QUERY_POINTER_ATTR
Definition: ntddvdeo.h:125
#define IOCTL_VIDEO_SET_POINTER_ATTR
Definition: ntddvdeo.h:164
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
#define IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY
Definition: ntddvdeo.h:182
#define _Inout_
Definition: ms_sal.h:378
#define INFO_(ch,...)
Definition: debug.h:159
static BOOLEAN InbvMonitoring
Definition: dispatch.c:35
struct _Entry Entry
Definition: kefuncs.h:627
#define IOCTL_VIDEO_REGISTER_VDM
Definition: ntddvdeo.h:47
VIDEO_WIN32K_CALLBACKS_PARAMS_TYPE CalloutType
Definition: ntddvdeo.h:250
static VOID NTAPI InbvMonitorThread(_In_ PVOID Context)
Definition: dispatch.c:208
#define IRP_MN_QUERY_POWER
NTSTATUS NTAPI IntVideoPortDispatchFdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1010
#define IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES
Definition: ntddvdeo.h:128
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
#define _Out_
Definition: ms_sal.h:345
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define IRP_MJ_SHUTDOWN
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4640
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _STATUS_BLOCK * PSTATUS_BLOCK
NTSTATUS NTAPI IntVideoPortDispatchCleanup(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1101
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
#define IOCTL_VIDEO_DISABLE_CURSOR
Definition: ntddvdeo.h:77
struct _VIDEO_DEVICE_SESSION_STATUS VIDEO_DEVICE_SESSION_STATUS
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:198
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_VIDEO_SET_COLOR_LUT_DATA
Definition: ntddvdeo.h:185
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
#define IOCTL_VIDEO_ENABLE_VDM
Definition: ntddvdeo.h:41
#define FILE_OPENED
Definition: nt_native.h:769
#define IOCTL_VIDEO_SET_CHILD_STATE_CONFIGURATION
Definition: ntddvdeo.h:146
#define IOCTL_VIDEO_GET_POWER_MANAGEMENT
Definition: ntddvdeo.h:98
NTSTATUS NTAPI IntVideoPortForwardIrpAndWaitCompletionRoutine(PDEVICE_OBJECT Fdo, PIRP Irp, PVOID Context)
Definition: dispatch.c:919
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
PCM_RESOURCE_LIST AllocatedResources
Definition: videoprt.h:94
#define IOCTL_VIDEO_HANDLE_VIDEOPARAMETERS
Definition: ntddvdeo.h:65
#define IOCTL_VIDEO_RESET_DEVICE
Definition: ntddvdeo.h:137
#define LOW_REALTIME_PRIORITY
#define IOCTL_VIDEO_MAP_VIDEO_MEMORY
Definition: ntddvdeo.h:104
VOID(NTAPI * PVIDEO_WIN32K_CALLOUT)(_In_ PVOID Params)
Definition: ntddvdeo.h:258
#define IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:53
PKPROCESS CsrProcess
Definition: videoprt.c:39
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
if(dx==0 &&dy==0)
Definition: linetemp.h:174
ULONG InputBufferLength
Definition: video.h:333
NTSTATUS NTAPI IntVideoPortDispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:718
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define NO_ERROR
Definition: dderror.h:5
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
PSTR IoctlName(ULONG Ioctl)
Definition: dispatch.c:447
#define IOCTL_VIDEO_GET_BANK_SELECT_CODE
Definition: ntddvdeo.h:92
#define IOCTL_VIDEO_DISABLE_POINTER
Definition: ntddvdeo.h:80
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 OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define IOCTL_VIDEO_FREE_PUBLIC_ACCESS_RANGES
Definition: ntddvdeo.h:89
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1044
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define IOCTL_VIDEO_ENUM_MONITOR_PDO
Definition: ntddvdeo.h:59
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_SEH2_TRY
Definition: create.c:4226
#define IOCTL_VIDEO_QUERY_CURRENT_MODE
Definition: ntddvdeo.h:113
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IOCTL_VIDEO_SET_CURRENT_MODE
Definition: ntddvdeo.h:152
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in ULONG Ioctl
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2868
UCHAR KIRQL
Definition: env_spec_w32.h:591
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
static BOOLEAN NTAPI IntVideoPortResetDisplayParameters(ULONG Columns, ULONG Rows)
Definition: dispatch.c:168
static NTSTATUS IntVideoPortInbvCleanup(IN PDEVICE_OBJECT DeviceObject)
Definition: dispatch.c:300
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define IOCTL_VIDEO_MONITOR_DEVICE
Definition: ntddvdeo.h:56
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:62
#define IRP_MN_QUERY_REMOVE_DEVICE
#define IOCTL_VIDEO_SET_PALETTE_REGISTERS
Definition: ntddvdeo.h:161
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
VOID NTAPI IntVideoPortUnload(PDRIVER_OBJECT DriverObject)
Definition: dispatch.c:1175
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define IOCTL_VIDEO_SET_CURSOR_POSITION
Definition: ntddvdeo.h:158
unsigned char BOOLEAN
static BOOLEAN NTAPI IntVideoPortResetDisplayParametersEx(_In_ ULONG Columns, _In_ ULONG Rows, _In_ BOOLEAN CalledByInbv)
Definition: dispatch.c:72
_In_ ULONG Rows
Definition: haltypes.h:7
#define _In_
Definition: ms_sal.h:308
#define IoCompleteRequest
Definition: irp.c:1240
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:42
#define IOCTL_VIDEO_QUERY_CURSOR_ATTR
Definition: ntddvdeo.h:116
NTSTATUS NTAPI IntInitializeVideoAddressSpace(VOID)
Definition: int10.c:200
static NTSTATUS VideoPortInitWin32kCallbacks(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:624
NTSTATUS NTAPI IntVideoPortDispatchClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:433
static NTSTATUS IntVideoPortInbvInitialize(VOID)
Definition: dispatch.c:274
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
ULONG OutputBufferLength
Definition: video.h:335
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:152
#define IOCTL_VIDEO_SET_POWER_MANAGEMENT
Definition: ntddvdeo.h:170
#define IOCTL_VIDEO_SET_CURSOR_ATTR
Definition: ntddvdeo.h:155
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IOCTL_VIDEO_UNMAP_VIDEO_MEMORY
Definition: ntddvdeo.h:179
BOOLEAN FASTCALL KeTestSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:475
#define IOCTL_VIDEO_ENABLE_CURSOR
Definition: ntddvdeo.h:83
#define IRP_MN_QUERY_STOP_DEVICE
#define IOCTL_VIDEO_QUERY_CURSOR_POSITION
Definition: ntddvdeo.h:119
Status
Definition: gdiplustypes.h:24
#define IOCTL_VIDEO_SWITCH_DUALVIEW
Definition: ntddvdeo.h:176
#define TRACE_(x)
Definition: compat.h:76
int64_t LONGLONG
Definition: typedefs.h:68
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
ULONG NTAPI PsGetCurrentProcessSessionId(VOID)
Definition: process.c:1133
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
static HANDLE InbvThreadHandle
Definition: dispatch.c:34
#define IRP_MN_STOP_DEVICE
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:221
#define IRP_MN_START_DEVICE
#define ObDereferenceObject
Definition: obfuncs.h:203
NTSTATUS NTAPI IntVideoPortDispatchSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1153
#define IOCTL_VIDEO_PREPARE_FOR_EARECOVERY
Definition: ntddvdeo.h:74
struct _VIDEO_WIN32K_CALLBACKS VIDEO_WIN32K_CALLBACKS
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:113
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
#define IO_VIDEO_INCREMENT
Definition: iotypes.h:609
static ULONG ResourceCount
Definition: inbv.c:92
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:621
#define IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:200
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3375
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
#define IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS
Definition: ntddvdeo.h:194
#define InterlockedDecrement
Definition: armddk.h:52
#define IOCTL_VIDEO_LOAD_AND_SET_FONT
Definition: ntddvdeo.h:101
NTSTATUS NTAPI IntVideoPortAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: dispatch.c:334
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define IOCTL_VIDEO_DISABLE_VDM
Definition: ntddvdeo.h:44
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define VOID
Definition: acefi.h:82
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1877
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:318
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
#define IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
Definition: ntddvdeo.h:122
#define IRP_MN_SET_POWER
#define IOCTL_VIDEO_QUERY_AVAIL_MODES
Definition: ntddvdeo.h:107
Definition: typedefs.h:119
#define IOCTL_VIDEO_SHARE_VIDEO_MEMORY
Definition: ntddvdeo.h:173
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
static const COLUMN_LIST Columns[]
Definition: listview.c:19
_SEH2_END
Definition: create.c:4400
NTSTATUS NTAPI IntVideoPortForwardIrpAndWait(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatch.c:982
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define IOCTL_VIDEO_VALIDATE_CHILD_STATE_CONFIGURATION
Definition: ntddvdeo.h:188
#define InterlockedIncrement
Definition: armddk.h:53
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
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
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1327
unsigned short USHORT
Definition: pedump.c:61
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:582
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
signed char * PSTR
Definition: retypes.h:7
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
NTSTATUS NTAPI IntVideoPortPnPStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:840
PSTATUS_BLOCK StatusBlock
Definition: video.h:331
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
static VOID VideoPortWin32kCallout(_In_ PVIDEO_WIN32K_CALLBACKS_PARAMS CallbackParams)
Definition: dispatch.c:40
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_MN_QUERY_DEVICE_RELATIONS
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
#define IOCTL_VIDEO_GET_CHILD_STATE
Definition: ntddvdeo.h:95
NTSTATUS NTAPI IntVideoPortDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1087
#define IOCTL_VIDEO_ENABLE_POINTER
Definition: ntddvdeo.h:86
#define IOCTL_VIDEO_QUERY_PUBLIC_ACCESS_RANGES
Definition: ntddvdeo.h:134
struct tagContext Context
Definition: acpixf.h:1034
#define ObReferenceObject
Definition: obfuncs.h:204
NTSTATUS NTAPI IntVideoPortDispatchOpen(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:369
#define IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:197
NTSTATUS NTAPI IntVideoPortQueryBusRelations(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatch.c:934
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:127
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define ULONG_PTR
Definition: config.h:101
uint32_t * PULONG_PTR
Definition: typedefs.h:65
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
LIST_ENTRY HwResetAdaptersList
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
static NTSTATUS VideoPortForwardDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:651
#define IRP_MN_CANCEL_STOP_DEVICE
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:553
#define KeGetCurrentThread
Definition: hal.h:55
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define IOCTL_VIDEO_RESTORE_HARDWARE_STATE
Definition: ntddvdeo.h:140
NTSTATUS NTAPI IntVideoPortFilterResourceRequirements(IN PDEVICE_OBJECT DeviceObject, IN PIO_STACK_LOCATION IrpStack, IN PIRP Irp)
Definition: resource.c:77
signed int * PLONG
Definition: retypes.h:5
#define IOCTL_VIDEO_USE_DEVICE_IN_SESSION
Definition: ntddvdeo.h:71
static PVIDEO_WIN32K_CALLOUT Win32kCallout
Definition: dispatch.c:33
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
#define WARN_(ch,...)
Definition: debug.h:157
base of all file and directory entries
Definition: entries.h:82
#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
LONGLONG QuadPart
Definition: typedefs.h:114
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:149
#define IOCTL_VIDEO_SET_BANK_POSITION
Definition: ntddvdeo.h:191
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10