ReactOS  0.4.15-dev-5137-g826bd41
device.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * PURPOSE: GDI Driver Device Functions
5  * FILE: win32ss/gdi/eng/device.c
6  * PROGRAMER: Jason Filby
7  * Timo Kreuzer
8  */
9 
10 #include <win32k.h>
11 #include <ntddvdeo.h>
12 
13 DBG_DEFAULT_CHANNEL(EngDev);
14 
17 
21 static ULONG giDevNum = 1;
22 
23 CODE_SEG("INIT")
25 NTAPI
27 {
31 
32  return STATUS_SUCCESS;
33 }
34 
37 {
38  ULONG iDevNum, iVGACompatible = -1, ulMaxObjectNumber = 0;
39  WCHAR awcDeviceName[20], awcWinDeviceName[20];
40  UNICODE_STRING ustrDeviceName;
41  WCHAR awcBuffer[256];
43  PGRAPHICS_DEVICE pGraphicsDevice;
44  ULONG cbValue;
45  HKEY hkey;
46 
47  /* Open the key for the adapters */
48  Status = RegOpenKey(L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP\\VIDEO", &hkey);
49  if (!NT_SUCCESS(Status))
50  {
51  ERR("Could not open HARDWARE\\DEVICEMAP\\VIDEO registry key:0x%lx\n", Status);
52  return Status;
53  }
54 
55  /* Read the name of the VGA adapter */
56  cbValue = sizeof(awcDeviceName);
57  Status = RegQueryValue(hkey, L"VgaCompatible", REG_SZ, awcDeviceName, &cbValue);
58  if (NT_SUCCESS(Status))
59  {
60  iVGACompatible = _wtoi(&awcDeviceName[sizeof("\\Device\\Video")-1]);
61  ERR("VGA adapter = %lu\n", iVGACompatible);
62  }
63 
64  /* Get the maximum mumber of adapters */
65  if (!RegReadDWORD(hkey, L"MaxObjectNumber", &ulMaxObjectNumber))
66  {
67  ERR("Could not read MaxObjectNumber, defaulting to 0.\n");
68  }
69 
70  TRACE("Found %lu devices\n", ulMaxObjectNumber + 1);
71 
72  /* Loop through all adapters */
73  for (iDevNum = 0; iDevNum <= ulMaxObjectNumber; iDevNum++)
74  {
75  /* Create the adapter's key name */
76  swprintf(awcDeviceName, L"\\Device\\Video%lu", iDevNum);
77 
78  /* Create the display device name */
79  swprintf(awcWinDeviceName, L"\\\\.\\DISPLAY%lu", iDevNum + 1);
80  RtlInitUnicodeString(&ustrDeviceName, awcWinDeviceName);
81 
82  /* Check if the device exists already */
83  pGraphicsDevice = EngpFindGraphicsDevice(&ustrDeviceName, iDevNum);
84  if (pGraphicsDevice != NULL)
85  {
86  continue;
87  }
88 
89  /* Read the reg key name */
90  cbValue = sizeof(awcBuffer);
91  Status = RegQueryValue(hkey, awcDeviceName, REG_SZ, awcBuffer, &cbValue);
92  if (!NT_SUCCESS(Status))
93  {
94  ERR("failed to query the registry path:0x%lx\n", Status);
95  continue;
96  }
97 
98  /* Initialize the driver for this device */
99  pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer);
100  if (!pGraphicsDevice) continue;
101 
102  /* Check if this is a VGA compatible adapter */
103  if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
104  {
105  /* Save this as the VGA adapter */
106  if (!gpVgaGraphicsDevice)
107  {
108  gpVgaGraphicsDevice = pGraphicsDevice;
109  TRACE("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
110  }
111  }
112 
113  /* Set the first one as primary device */
115  {
116  gpPrimaryGraphicsDevice = pGraphicsDevice;
117  TRACE("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice);
118  }
119  }
120 
121  /* Close the device map registry key */
122  ZwClose(hkey);
123 
124  return STATUS_SUCCESS;
125 }
126 
127 /* Open display settings registry key
128  * Returns NULL in case of error. */
129 static HKEY
131  _In_ PGRAPHICS_DEVICE pGraphicsDevice)
132 {
133  static const PWCHAR KEY_VIDEO = L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP\\VIDEO";
134  HKEY hKey;
135  WCHAR szDeviceKey[256];
136  ULONG cbSize;
138 
139  /* Open the device map registry key */
141  if (!NT_SUCCESS(Status))
142  {
143  ERR("Could not open HARDWARE\\DEVICEMAP\\VIDEO registry key: status 0x%08x\n", Status);
144  return NULL;
145  }
146 
147  /* Query the registry path */
148  cbSize = sizeof(szDeviceKey);
150  pGraphicsDevice->szNtDeviceName,
151  REG_SZ,
152  szDeviceKey,
153  &cbSize);
154  ZwClose(hKey);
155 
156  /* Open the registry key */
157  Status = RegOpenKey(szDeviceKey, &hKey);
158  if (!NT_SUCCESS(Status))
159  {
160  ERR("Could not open registry key '%S': status 0x%08x\n", szDeviceKey, Status);
161  return NULL;
162  }
163 
164  return hKey;
165 }
166 
167 NTSTATUS
169  _In_ PGRAPHICS_DEVICE pGraphicsDevice,
170  _Out_ PDEVMODEW pdm)
171 {
172  HKEY hKey;
174  RTL_QUERY_REGISTRY_TABLE DisplaySettingsTable[] =
175  {
176 #define READ(field, str) \
177  { \
178  NULL, \
179  RTL_QUERY_REGISTRY_DIRECT, \
180  L ##str, \
181  &pdm->field, \
182  REG_NONE, NULL, 0 \
183  },
184  READ(dmBitsPerPel, "DefaultSettings.BitsPerPel")
185  READ(dmPelsWidth, "DefaultSettings.XResolution")
186  READ(dmPelsHeight, "DefaultSettings.YResolution")
187  READ(dmDisplayFlags, "DefaultSettings.Flags")
188  READ(dmDisplayFrequency, "DefaultSettings.VRefresh")
189  READ(dmPanningWidth, "DefaultSettings.XPanning")
190  READ(dmPanningHeight, "DefaultSettings.YPanning")
191  READ(dmDisplayOrientation, "DefaultSettings.Orientation")
192  READ(dmDisplayFixedOutput, "DefaultSettings.FixedOutput")
193  READ(dmPosition.x, "Attach.RelativeX")
194  READ(dmPosition.y, "Attach.RelativeY")
195 #undef READ
196  {0}
197  };
198 
199  hKey = EngpGetRegistryHandleFromDeviceMap(pGraphicsDevice);
200  if (!hKey)
201  return STATUS_UNSUCCESSFUL;
202 
204  (PWSTR)hKey,
205  DisplaySettingsTable,
206  NULL,
207  NULL);
208 
209  ZwClose(hKey);
210  return Status;
211 }
212 
213 DWORD
215  _In_ PGRAPHICS_DEVICE pGraphicsDevice)
216 {
217  HKEY hKey;
218  DWORD dwAccelerationLevel = 0;
219  RTL_QUERY_REGISTRY_TABLE DisplaySettingsTable[] =
220  {
221  {
222  NULL,
224  L"Acceleration.Level",
225  &dwAccelerationLevel,
226  REG_NONE, NULL, 0
227  },
228  {0}
229  };
230 
231  hKey = EngpGetRegistryHandleFromDeviceMap(pGraphicsDevice);
232  if (!hKey)
233  return 0;
234 
236  (PWSTR)hKey,
237  DisplaySettingsTable,
238  NULL,
239  NULL);
240  ZwClose(hKey);
241 
242  return dwAccelerationLevel;
243 }
244 
245 extern VOID
247 
248 // PVIDEO_WIN32K_CALLOUT
249 VOID
250 NTAPI
252  _In_ PVOID Params)
253 {
254 /*
255  * IMPORTANT NOTICE!! On Windows XP/2003 this function triggers the creation of
256  * a specific VideoPortCalloutThread() system thread using the same mechanism
257  * as the RIT/desktop/Ghost system threads.
258  */
259 
261 
262  TRACE("VideoPortCallout(0x%p, 0x%x)\n",
263  CallbackParams, CallbackParams ? CallbackParams->CalloutType : -1);
264 
265  if (!CallbackParams)
266  return;
267 
268  switch (CallbackParams->CalloutType)
269  {
271  {
272  TRACE("VideoPortCallout: VideoFindAdapterCallout called - Param = %s\n",
273  CallbackParams->Param ? "TRUE" : "FALSE");
274  if (CallbackParams->Param == TRUE)
275  {
276  /* Re-enable the display */
278  }
279  else
280  {
281  /* Disable the display */
282  NOTHING; // Nothing to do for the moment...
283  }
284 
285  CallbackParams->Status = STATUS_SUCCESS;
286  break;
287  }
288 
292  case VideoWakeupCallout:
298  ERR("VideoPortCallout: CalloutType 0x%x is UNIMPLEMENTED!\n", CallbackParams->CalloutType);
299  CallbackParams->Status = STATUS_NOT_IMPLEMENTED;
300  break;
301 
302  default:
303  ERR("VideoPortCallout: Unknown CalloutType 0x%x\n", CallbackParams->CalloutType);
304  CallbackParams->Status = STATUS_UNSUCCESSFUL;
305  break;
306  }
307 }
308 
310 NTAPI
312  _In_ PUNICODE_STRING pustrDeviceName,
313  _In_ PUNICODE_STRING pustrDiplayDrivers,
314  _In_ PUNICODE_STRING pustrDescription)
315 {
316  PGRAPHICS_DEVICE pGraphicsDevice;
318  PFILE_OBJECT pFileObject;
320  VIDEO_WIN32K_CALLBACKS Win32kCallbacks;
321  ULONG ulReturn;
322  PWSTR pwsz;
323  ULONG cj;
324 
325  TRACE("EngpRegisterGraphicsDevice(%wZ)\n", pustrDeviceName);
326 
327  /* Allocate a GRAPHICS_DEVICE structure */
328  pGraphicsDevice = ExAllocatePoolWithTag(PagedPool,
329  sizeof(GRAPHICS_DEVICE),
331  if (!pGraphicsDevice)
332  {
333  ERR("ExAllocatePoolWithTag failed\n");
334  return NULL;
335  }
336 
337  /* Try to open and enable the device */
338  Status = IoGetDeviceObjectPointer(pustrDeviceName,
340  &pFileObject,
341  &pDeviceObject);
342  if (!NT_SUCCESS(Status))
343  {
344  ERR("Could not open device %wZ, 0x%lx\n", pustrDeviceName, Status);
345  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
346  return NULL;
347  }
348 
349  /* Copy the device and file object pointers */
350  pGraphicsDevice->DeviceObject = pDeviceObject;
351  pGraphicsDevice->FileObject = pFileObject;
352 
353  /* Initialize and register the device with videoprt for Win32k callbacks */
354  Win32kCallbacks.PhysDisp = pGraphicsDevice;
355  Win32kCallbacks.Callout = VideoPortCallout;
356  // Reset the data being returned prior to the call.
357  Win32kCallbacks.bACPI = FALSE;
358  Win32kCallbacks.pPhysDeviceObject = NULL;
359  Win32kCallbacks.DualviewFlags = 0;
360  Status = (NTSTATUS)EngDeviceIoControl((HANDLE)pDeviceObject,
362  &Win32kCallbacks,
363  sizeof(Win32kCallbacks),
364  &Win32kCallbacks,
365  sizeof(Win32kCallbacks),
366  &ulReturn);
367  if (Status != ERROR_SUCCESS)
368  {
369  ERR("EngDeviceIoControl(0x%p, IOCTL_VIDEO_INIT_WIN32K_CALLBACKS) failed, Status 0x%lx\n",
371  }
372  // TODO: Set flags according to the results.
373  // if (Win32kCallbacks.bACPI)
374  // if (Win32kCallbacks.DualviewFlags & ???)
375  pGraphicsDevice->PhysDeviceHandle = Win32kCallbacks.pPhysDeviceObject;
376 
377  /* FIXME: Enumerate children monitor devices for this video adapter
378  *
379  * - Force the adapter to re-enumerate its monitors:
380  * IoSynchronousInvalidateDeviceRelations(pdo, BusRelations)
381  *
382  * - Retrieve all monitor PDOs from VideoPrt:
383  * EngDeviceIoControl(0x%p, IOCTL_VIDEO_ENUM_MONITOR_PDO)
384  *
385  * - Initialize these fields and structures accordingly:
386  * pGraphicsDevice->dwMonCnt
387  * pGraphicsDevice->pvMonDev[0..dwMonCnt-1]
388  */
389 
390  /* Copy the device name */
391  RtlStringCbCopyNW(pGraphicsDevice->szNtDeviceName,
392  sizeof(pGraphicsDevice->szNtDeviceName),
393  pustrDeviceName->Buffer,
394  pustrDeviceName->Length);
395 
396  /* Create a Win32 device name (FIXME: virtual devices!) */
397  RtlStringCbPrintfW(pGraphicsDevice->szWinDeviceName,
398  sizeof(pGraphicsDevice->szWinDeviceName),
399  L"\\\\.\\DISPLAY%d",
400  (int)giDevNum);
401 
402  /* Allocate a buffer for the strings */
403  cj = pustrDiplayDrivers->Length + pustrDescription->Length + sizeof(WCHAR);
405  if (!pwsz)
406  {
407  ERR("Could not allocate string buffer\n");
408  ASSERT(FALSE); // FIXME
409  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
410  return NULL;
411  }
412 
413  /* Copy the display driver names */
414  pGraphicsDevice->pDiplayDrivers = pwsz;
415  RtlCopyMemory(pGraphicsDevice->pDiplayDrivers,
416  pustrDiplayDrivers->Buffer,
417  pustrDiplayDrivers->Length);
418 
419  /* Copy the description */
420  pGraphicsDevice->pwszDescription = pwsz + pustrDiplayDrivers->Length / sizeof(WCHAR);
421  RtlCopyMemory(pGraphicsDevice->pwszDescription,
422  pustrDescription->Buffer,
423  pustrDescription->Length);
424  pGraphicsDevice->pwszDescription[pustrDescription->Length/sizeof(WCHAR)] = 0;
425 
426  /* Initialize the pdevmodeInfo list */
427  pGraphicsDevice->pdevmodeInfo = NULL;
428 
429  // FIXME: initialize state flags
430  pGraphicsDevice->StateFlags = 0;
431 
432  /* Create the mode list */
433  pGraphicsDevice->pDevModeList = NULL;
434 
435  /* Lock loader */
437 
438  /* Insert the device into the global list */
439  pGraphicsDevice->pNextGraphicsDevice = NULL;
441  gpGraphicsDeviceLast->pNextGraphicsDevice = pGraphicsDevice;
442  gpGraphicsDeviceLast = pGraphicsDevice;
444  gpGraphicsDeviceFirst = pGraphicsDevice;
445 
446  /* Increment the device number */
447  giDevNum++;
448 
449  /* Unlock loader */
451  TRACE("Prepared %lu modes for %ls\n", pGraphicsDevice->cDevModes, pGraphicsDevice->pwszDescription);
452 
453  /* HACK: already in graphic mode; display wallpaper on this new display */
455  {
456  UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
457  UNICODE_STRING DisplayName;
458  HDC hdc;
459  RtlInitUnicodeString(&DisplayName, pGraphicsDevice->szWinDeviceName);
460  hdc = IntGdiCreateDC(&DriverName, &DisplayName, NULL, NULL, FALSE);
462  }
463 
464  return pGraphicsDevice;
465 }
466 
468 NTAPI
470  _In_opt_ PUNICODE_STRING pustrDevice,
471  _In_ ULONG iDevNum)
472 {
473  UNICODE_STRING ustrCurrent;
474  PGRAPHICS_DEVICE pGraphicsDevice;
475  ULONG i;
476  TRACE("EngpFindGraphicsDevice('%wZ', %lu)\n",
477  pustrDevice, iDevNum);
478 
479  /* Lock list */
481 
482  if (pustrDevice && pustrDevice->Buffer)
483  {
484  /* Find specified video adapter by name */
485  for (pGraphicsDevice = gpGraphicsDeviceFirst;
486  pGraphicsDevice;
487  pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice)
488  {
489  /* Compare the device name */
490  RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);
491  if (RtlEqualUnicodeString(&ustrCurrent, pustrDevice, FALSE))
492  {
493  break;
494  }
495  }
496 
497  if (pGraphicsDevice)
498  {
499  /* Validate selected monitor number */
500 #if 0
501  if (iDevNum >= pGraphicsDevice->dwMonCnt)
502  pGraphicsDevice = NULL;
503 #else
504  /* FIXME: dwMonCnt not initialized, see EngpRegisterGraphicsDevice */
505 #endif
506  }
507  }
508  else
509  {
510  /* Select video adapter by device number */
511  for (pGraphicsDevice = gpGraphicsDeviceFirst, i = 0;
512  pGraphicsDevice && i < iDevNum;
513  pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice, i++);
514  }
515 
516  /* Unlock list */
518 
519  return pGraphicsDevice;
520 }
521 
522 static
523 NTSTATUS
525  _In_ PFILE_OBJECT pFileObject,
526  _In_ ULONG ulMajorFunction,
527  _In_reads_(nBufferSize) PVOID lpBuffer,
528  _In_ SIZE_T nBufferSize,
529  _In_ ULONGLONG ullStartOffset,
530  _Out_ PULONG_PTR lpInformation)
531 {
533  KEVENT Event;
534  PIRP pIrp;
537  LARGE_INTEGER liStartOffset;
538 
539  /* Get corresponding device object */
541  if (!pDeviceObject)
542  {
544  }
545 
546  /* Initialize an event */
548 
549  /* Build IRP */
550  liStartOffset.QuadPart = ullStartOffset;
551  pIrp = IoBuildSynchronousFsdRequest(ulMajorFunction,
553  lpBuffer,
554  (ULONG)nBufferSize,
555  &liStartOffset,
556  &Event,
557  &Iosb);
558  if (!pIrp)
559  {
561  }
562 
563  /* Call the driver */
565 
566  /* Wait if neccessary */
567  if (STATUS_PENDING == Status)
568  {
570  Status = Iosb.Status;
571  }
572 
573  /* Return information to the caller about the operation. */
574  *lpInformation = Iosb.Information;
575 
576  /* Return NTSTATUS */
577  return Status;
578 }
579 
580 VOID
581 APIENTRY
583  _In_ PFILE_OBJECT pFileObject,
586  _Out_ PSIZE_T lpBytesWritten)
587 {
589 
590  status = EngpFileIoRequest(pFileObject,
591  IRP_MJ_WRITE,
592  lpBuffer,
593  nLength,
594  0,
595  lpBytesWritten);
596  if (!NT_SUCCESS(status))
597  {
598  *lpBytesWritten = 0;
599  }
600 }
601 
602 _Success_(return>=0)
603 NTSTATUS
604 APIENTRY
605 EngFileIoControl(
606  _In_ PFILE_OBJECT pFileObject,
608  _In_reads_(nInBufferSize) PVOID lpInBuffer,
609  _In_ SIZE_T nInBufferSize,
610  _Out_writes_(nOutBufferSize) PVOID lpOutBuffer,
611  _In_ SIZE_T nOutBufferSize,
612  _Out_ PULONG_PTR lpInformation)
613 {
615  KEVENT Event;
616  PIRP pIrp;
619 
620  /* Get corresponding device object */
622  if (!pDeviceObject)
623  {
625  }
626 
627  /* Initialize an event */
629 
630  /* Build IO control IRP */
633  lpInBuffer,
634  (ULONG)nInBufferSize,
635  lpOutBuffer,
636  (ULONG)nOutBufferSize,
637  FALSE,
638  &Event,
639  &Iosb);
640  if (!pIrp)
641  {
643  }
644 
645  /* Call the driver */
647 
648  /* Wait if neccessary */
649  if (Status == STATUS_PENDING)
650  {
652  Status = Iosb.Status;
653  }
654 
655  /* Return information to the caller about the operation. */
656  *lpInformation = Iosb.Information;
657 
658  /* This function returns NTSTATUS */
659  return Status;
660 }
661 
662 /*
663  * @implemented
664  */
665 _Success_(return==0)
666 DWORD
667 APIENTRY
668 EngDeviceIoControl(
669  _In_ HANDLE hDevice,
676 {
677  PIRP Irp;
679  KEVENT Event;
682 
683  TRACE("EngDeviceIoControl() called\n");
684 
685  if (!hDevice)
686  {
687  return ERROR_INVALID_HANDLE;
688  }
689 
691 
692  DeviceObject = (PDEVICE_OBJECT) hDevice;
693 
695  DeviceObject,
696  lpInBuffer,
698  lpOutBuffer,
700  FALSE,
701  &Event,
702  &Iosb);
703  if (!Irp) return ERROR_NOT_ENOUGH_MEMORY;
704 
706 
707  if (Status == STATUS_PENDING)
708  {
710  Status = Iosb.Status;
711  }
712 
713  TRACE("EngDeviceIoControl(): Returning %X/%X\n", Iosb.Status,
714  Iosb.Information);
715 
716  /* Return information to the caller about the operation. */
717  *lpBytesReturned = (DWORD)Iosb.Information;
718 
719  /* Convert NT status values to win32 error codes. */
720  switch (Status)
721  {
724 
726  return ERROR_MORE_DATA;
727 
729  return ERROR_INVALID_FUNCTION;
730 
733 
736 
738  return ERROR_DEV_NOT_EXIST;
739 
740  case STATUS_PENDING:
741  return ERROR_IO_PENDING;
742  }
743 
744  return Status;
745 }
746 
747 /* EOF */
static const PWCHAR KEY_VIDEO
Definition: display.c:15
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
#define IN
Definition: typedefs.h:39
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
DWORD EngpGetDisplayDriverAccelerationLevel(_In_ PGRAPHICS_DEVICE pGraphicsDevice)
Definition: device.c:214
#define NOTHING
Definition: input_list.c:10
_In_ ULONG cj
Definition: winddi.h:3540
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ DWORD _In_reads_(nInBufferSize)
Definition: device.c:608
#define _In_opt_
Definition: ms_sal.h:309
NTSTATUS EngpGetDisplayDriverParameters(_In_ PGRAPHICS_DEVICE pGraphicsDevice, _Out_ PDEVMODEW pdm)
Definition: device.c:168
static PGRAPHICS_DEVICE gpGraphicsDeviceLast
Definition: device.c:19
#define ERROR_SUCCESS
Definition: deptool.c:10
PDEVICE_OBJECT DeviceObject
Definition: pdevobj.h:63
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
VIDEO_WIN32K_CALLBACKS_PARAMS_TYPE CalloutType
Definition: ntddvdeo.h:250
_In_ DWORD _In_ DWORD _In_ DWORD cjOutBufferSize
Definition: winddi.h:1704
#define _Out_
Definition: ms_sal.h:345
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
WCHAR szWinDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:60
WCHAR szNtDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:59
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _DEVICE_OBJECT * PDEVICE_OBJECT
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_Success_(return >=0) NTSTATUS APIENTRY EngFileIoControl(_In_ PFILE_OBJECT pFileObject
uint16_t * PWSTR
Definition: typedefs.h:56
DWORD StateFlags
Definition: pdevobj.h:66
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
LONG NTSTATUS
Definition: precomp.h:26
static HDC
Definition: imagelist.c:92
_In_ DWORD nLength
Definition: wincon.h:473
static HKEY EngpGetRegistryHandleFromDeviceMap(_In_ PGRAPHICS_DEVICE pGraphicsDevice)
Definition: device.c:130
PDEVMODEENTRY pDevModeList
Definition: pdevobj.h:70
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
PGRAPHICS_DEVICE gpVgaGraphicsDevice
Definition: device.c:16
IN PVIDEO_WIN32K_CALLOUT Callout
Definition: ntddvdeo.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
FxIrp * pIrp
PGRAPHICS_DEVICE NTAPI InitDisplayDriver(IN PWSTR pwszDeviceName, IN PWSTR pwszRegKey)
Definition: display.c:66
PGRAPHICS_DEVICE gpPrimaryGraphicsDevice
Definition: device.c:15
#define ERROR_IO_PENDING
Definition: dderror.h:15
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 DWORD
Definition: nt_native.h:44
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
VOID UserRefreshDisplay(IN PPDEVOBJ ppdev)
Definition: display.c:193
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
#define L(x)
Definition: ntvdm.h:50
ULONG_PTR * PSIZE_T
Definition: typedefs.h:80
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:62
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSTRSAFEAPI RtlStringCbCopyNW(_Out_writes_bytes_(cbDest) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:416
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
LPWSTR pwszDescription
Definition: pdevobj.h:72
_In_ DWORD _In_ DWORD cjInBufferSize
Definition: winddi.h:1702
VOID NTAPI VideoPortCallout(_In_ PVOID Params)
Definition: device.c:251
static PGRAPHICS_DEVICE gpGraphicsDeviceFirst
Definition: device.c:18
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
#define _In_
Definition: ms_sal.h:308
BOOL FASTCALL IntPaintDesktop(HDC hDC)
Definition: desktop.c:1827
switch(r->id)
Definition: btrfs.c:3046
_In_ DWORD dwIoControlCode
Definition: device.c:607
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define _Out_writes_bytes_opt_(size)
Definition: ms_sal.h:351
PDEVICE_OBJECT PhysDeviceHandle
Definition: pdevobj.h:64
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
struct _GRAPHICS_DEVICE * pNextGraphicsDevice
Definition: pdevobj.h:61
#define ASSERT(a)
Definition: mode.c:44
DWORD_PTR HSEMAPHORE
Definition: axcore.idl:60
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
LPWSTR pDiplayDrivers
Definition: pdevobj.h:71
ULONG cDevModes
Definition: pdevobj.h:69
uint64_t ULONGLONG
Definition: typedefs.h:67
OUT HANDLE pPhysDeviceObject
Definition: ntddvdeo.h:265
BOOL NTAPI RegReadDWORD(HKEY hkey, PWSTR pwszValue, PDWORD pdwData)
Definition: registry.c:150
unsigned long DWORD
Definition: ntddk_ex.h:95
static HSEMAPHORE ghsemGraphicsDeviceList
Definition: device.c:20
DWORD dwMonCnt
Definition: pdevobj.h:73
* PFILE_OBJECT
Definition: iotypes.h:1998
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define READ(field, str)
HDC hdc
Definition: main.c:9
#define NTSTATUS
Definition: precomp.h:20
#define GDITAG_DRVSUP
Definition: tags.h:77
#define VOID
Definition: acefi.h:82
#define RTL_REGISTRY_HANDLE
Definition: nt_native.h:168
struct _VIDEO_WIN32K_CALLBACKS_PARAMS * PVIDEO_WIN32K_CALLBACKS_PARAMS
PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice(_In_opt_ PUNICODE_STRING pustrDevice, _In_ ULONG iDevNum)
Definition: device.c:469
int _cdecl swprintf(const WCHAR *,...)
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define GDITAG_GDEVICE
Definition: tags.h:99
OUT ULONG DualviewFlags
Definition: ntddvdeo.h:266
#define ERR(fmt,...)
Definition: debug.h:110
ULONG_PTR SIZE_T
Definition: typedefs.h:80
NTSTATUS EngpUpdateGraphicsDeviceList(VOID)
Definition: device.c:36
DBG_DEFAULT_CHANNEL(EngDev)
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
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
static ULONG giDevNum
Definition: device.c:21
FxAutoRegKey hKey
PPDEVOBJ ppdevGlobal
Definition: mdevobj.h:16
HDC FASTCALL IntGdiCreateDC(PUNICODE_STRING Driver, PUNICODE_STRING pustrDevice, PVOID pUMdhpdev, CONST PDEVMODEW pdmInit, BOOL CreateAsIC)
Definition: dclife.c:1040
PMDEVOBJ gpmdev
Definition: mdevobj.c:14
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
_In_ DWORD _In_ DWORD _In_ DWORD _Out_ LPDWORD lpBytesReturned
Definition: winddi.h:1704
#define DISPLAY_DEVICE_VGA_COMPATIBLE
Definition: wingdi.h:1400
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define _In_reads_bytes_opt_(size)
Definition: ms_sal.h:322
NTSTATUS NTAPI InitDeviceImpl(VOID)
Definition: device.c:26
#define RegQueryValue
Definition: winreg.h:523
uint32_t * LPDWORD
Definition: typedefs.h:59
HSEMAPHORE WINAPI EngCreateSemaphore(VOID)
Definition: eng.c:75
return Iosb
Definition: create.c:4402
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
uint32_t * PULONG_PTR
Definition: typedefs.h:65
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define STATUS_SUCCESS
Definition: shellext.h:65
PGRAPHICS_DEVICE NTAPI EngpRegisterGraphicsDevice(_In_ PUNICODE_STRING pustrDeviceName, _In_ PUNICODE_STRING pustrDiplayDrivers, _In_ PUNICODE_STRING pustrDescription)
Definition: device.c:311
HDC ScreenDeviceContext
Definition: desktop.c:36
#define REG_NONE
Definition: nt_native.h:1492
VOID APIENTRY EngFileWrite(_In_ PFILE_OBJECT pFileObject, _In_reads_(nLength) PVOID lpBuffer, _In_ SIZE_T nLength, _Out_ PSIZE_T lpBytesWritten)
Definition: device.c:582
#define RegOpenKey
Definition: winreg.h:519
PDEVMODEINFO pdevmodeInfo
Definition: pdevobj.h:68
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
static SERVICE_STATUS status
Definition: service.c:31
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
static NTSTATUS EngpFileIoRequest(_In_ PFILE_OBJECT pFileObject, _In_ ULONG ulMajorFunction, _In_reads_(nBufferSize) PVOID lpBuffer, _In_ SIZE_T nBufferSize, _In_ ULONGLONG ullStartOffset, _Out_ PULONG_PTR lpInformation)
Definition: device.c:524
PFILE_OBJECT FileObject
Definition: pdevobj.h:75
#define APIENTRY
Definition: api.h:79
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
LONGLONG QuadPart
Definition: typedefs.h:114
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define _Out_writes_(size)
Definition: ms_sal.h:348
#define REG_SZ
Definition: layer.c:22
Definition: ps.c:97