ReactOS  0.4.15-dev-3287-gfec35dc
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];
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  RtlInitUnicodeString(&ustrDeviceName, awcDeviceName);
78 
79  /* Check if the device exists already */
80  pGraphicsDevice = EngpFindGraphicsDevice(&ustrDeviceName, iDevNum, 0);
81  if (pGraphicsDevice != NULL)
82  {
83  continue;
84  }
85 
86  /* Read the reg key name */
87  cbValue = sizeof(awcBuffer);
88  Status = RegQueryValue(hkey, awcDeviceName, REG_SZ, awcBuffer, &cbValue);
89  if (!NT_SUCCESS(Status))
90  {
91  ERR("failed to query the registry path:0x%lx\n", Status);
92  continue;
93  }
94 
95  /* Initialize the driver for this device */
96  pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer);
97  if (!pGraphicsDevice) continue;
98 
99  /* Check if this is a VGA compatible adapter */
100  if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
101  {
102  /* Save this as the VGA adapter */
103  if (!gpVgaGraphicsDevice)
104  {
105  gpVgaGraphicsDevice = pGraphicsDevice;
106  TRACE("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
107  }
108  }
109 
110  /* Set the first one as primary device */
112  {
113  gpPrimaryGraphicsDevice = pGraphicsDevice;
114  TRACE("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice);
115  }
116  }
117 
118  /* Close the device map registry key */
119  ZwClose(hkey);
120 
121  return STATUS_SUCCESS;
122 }
123 
124 BOOLEAN
126  _Inout_ PGRAPHICS_DEVICE pGraphicsDevice,
127  _In_ PDEVMODEW pdmDefault)
128 {
129  PWSTR pwsz;
130  PLDEVOBJ pldev;
131  PDEVMODEINFO pdminfo;
132  PDEVMODEW pdm, pdmEnd;
133  ULONG i, cModes = 0;
134  BOOLEAN bModeMatch = FALSE;
135 
136  ASSERT(pGraphicsDevice->pdevmodeInfo == NULL);
137  ASSERT(pGraphicsDevice->pDevModeList == NULL);
138 
139  pwsz = pGraphicsDevice->pDiplayDrivers;
140 
141  /* Loop through the driver names
142  * This is a REG_MULTI_SZ string */
143  for (; *pwsz; pwsz += wcslen(pwsz) + 1)
144  {
145  /* Try to load the display driver */
146  TRACE("Trying driver: %ls\n", pwsz);
147  pldev = EngLoadImageEx(pwsz, LDEV_DEVICE_DISPLAY);
148  if (!pldev)
149  {
150  ERR("Could not load driver: '%ls'\n", pwsz);
151  continue;
152  }
153 
154  /* Get the mode list from the driver */
155  pdminfo = LDEVOBJ_pdmiGetModes(pldev, pGraphicsDevice->DeviceObject);
156  if (!pdminfo)
157  {
158  ERR("Could not get mode list for '%ls'\n", pwsz);
159  continue;
160  }
161 
162  /* Attach the mode info to the device */
163  pdminfo->pdmiNext = pGraphicsDevice->pdevmodeInfo;
164  pGraphicsDevice->pdevmodeInfo = pdminfo;
165 
166  /* Loop all DEVMODEs */
167  pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode);
168  for (pdm = pdminfo->adevmode;
169  (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
170  pdm = (DEVMODEW*)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
171  {
172  /* Count this DEVMODE */
173  cModes++;
174 
175  /* Some drivers like the VBox driver don't fill the dmDeviceName
176  with the name of the display driver. So fix that here. */
177  RtlStringCbCopyW(pdm->dmDeviceName, sizeof(pdm->dmDeviceName), pwsz);
178  }
179 
180  // FIXME: release the driver again until it's used?
181  }
182 
183  if (!pGraphicsDevice->pdevmodeInfo || cModes == 0)
184  {
185  ERR("No devmodes\n");
186  return FALSE;
187  }
188 
189  /* Allocate an index buffer */
190  pGraphicsDevice->cDevModes = cModes;
191  pGraphicsDevice->pDevModeList = ExAllocatePoolWithTag(PagedPool,
192  cModes * sizeof(DEVMODEENTRY),
194  if (!pGraphicsDevice->pDevModeList)
195  {
196  ERR("No devmode list\n");
197  return FALSE;
198  }
199 
200  TRACE("Looking for mode %lux%lux%lu(%lu Hz)\n",
201  pdmDefault->dmPelsWidth,
202  pdmDefault->dmPelsHeight,
203  pdmDefault->dmBitsPerPel,
204  pdmDefault->dmDisplayFrequency);
205 
206  /* Loop through all DEVMODEINFOs */
207  for (pdminfo = pGraphicsDevice->pdevmodeInfo, i = 0;
208  pdminfo;
209  pdminfo = pdminfo->pdmiNext)
210  {
211  /* Calculate End of the DEVMODEs */
212  pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode);
213 
214  /* Loop through the DEVMODEs */
215  for (pdm = pdminfo->adevmode;
216  (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
217  pdm = (PDEVMODEW)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
218  {
219  TRACE(" %S has mode %lux%lux%lu(%lu Hz)\n",
220  pdm->dmDeviceName,
221  pdm->dmPelsWidth,
222  pdm->dmPelsHeight,
223  pdm->dmBitsPerPel,
224  pdm->dmDisplayFrequency);
225  /* Compare with the default entry */
226  if (!bModeMatch &&
227  pdm->dmBitsPerPel == pdmDefault->dmBitsPerPel &&
228  pdm->dmPelsWidth == pdmDefault->dmPelsWidth &&
229  pdm->dmPelsHeight == pdmDefault->dmPelsHeight)
230  {
231  pGraphicsDevice->iDefaultMode = i;
232  pGraphicsDevice->iCurrentMode = i;
233  TRACE("Found default entry: %lu '%ls'\n", i, pdm->dmDeviceName);
234  if (pdm->dmDisplayFrequency == pdmDefault->dmDisplayFrequency)
235  {
236  /* Uh oh, even the display frequency matches. */
237  bModeMatch = TRUE;
238  }
239  }
240 
241  /* Initialize the entry */
242  pGraphicsDevice->pDevModeList[i].dwFlags = 0;
243  pGraphicsDevice->pDevModeList[i].pdm = pdm;
244  i++;
245  }
246  }
247  return TRUE;
248 }
249 
250 extern VOID
252 
253 // PVIDEO_WIN32K_CALLOUT
254 VOID
255 NTAPI
257  _In_ PVOID Params)
258 {
259 /*
260  * IMPORTANT NOTICE!! On Windows XP/2003 this function triggers the creation of
261  * a specific VideoPortCalloutThread() system thread using the same mechanism
262  * as the RIT/desktop/Ghost system threads.
263  */
264 
266 
267  TRACE("VideoPortCallout(0x%p, 0x%x)\n",
268  CallbackParams, CallbackParams ? CallbackParams->CalloutType : -1);
269 
270  if (!CallbackParams)
271  return;
272 
273  switch (CallbackParams->CalloutType)
274  {
276  {
277  TRACE("VideoPortCallout: VideoFindAdapterCallout called - Param = %s\n",
278  CallbackParams->Param ? "TRUE" : "FALSE");
279  if (CallbackParams->Param == TRUE)
280  {
281  /* Re-enable the display */
283  }
284  else
285  {
286  /* Disable the display */
287  NOTHING; // Nothing to do for the moment...
288  }
289 
290  CallbackParams->Status = STATUS_SUCCESS;
291  break;
292  }
293 
297  case VideoWakeupCallout:
303  ERR("VideoPortCallout: CalloutType 0x%x is UNIMPLEMENTED!\n", CallbackParams->CalloutType);
304  CallbackParams->Status = STATUS_NOT_IMPLEMENTED;
305  break;
306 
307  default:
308  ERR("VideoPortCallout: Unknown CalloutType 0x%x\n", CallbackParams->CalloutType);
309  CallbackParams->Status = STATUS_UNSUCCESSFUL;
310  break;
311  }
312 }
313 
315 NTAPI
317  _In_ PUNICODE_STRING pustrDeviceName,
318  _In_ PUNICODE_STRING pustrDiplayDrivers,
319  _In_ PUNICODE_STRING pustrDescription,
320  _In_ PDEVMODEW pdmDefault)
321 {
322  PGRAPHICS_DEVICE pGraphicsDevice;
324  PFILE_OBJECT pFileObject;
326  VIDEO_WIN32K_CALLBACKS Win32kCallbacks;
327  ULONG ulReturn;
328  PWSTR pwsz;
329  ULONG cj;
330 
331  TRACE("EngpRegisterGraphicsDevice(%wZ)\n", pustrDeviceName);
332 
333  /* Allocate a GRAPHICS_DEVICE structure */
334  pGraphicsDevice = ExAllocatePoolWithTag(PagedPool,
335  sizeof(GRAPHICS_DEVICE),
337  if (!pGraphicsDevice)
338  {
339  ERR("ExAllocatePoolWithTag failed\n");
340  return NULL;
341  }
342 
343  /* Try to open and enable the device */
344  Status = IoGetDeviceObjectPointer(pustrDeviceName,
346  &pFileObject,
347  &pDeviceObject);
348  if (!NT_SUCCESS(Status))
349  {
350  ERR("Could not open device %wZ, 0x%lx\n", pustrDeviceName, Status);
351  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
352  return NULL;
353  }
354 
355  /* Copy the device and file object pointers */
356  pGraphicsDevice->DeviceObject = pDeviceObject;
357  pGraphicsDevice->FileObject = pFileObject;
358 
359  /* Initialize and register the device with videoprt for Win32k callbacks */
360  Win32kCallbacks.PhysDisp = pGraphicsDevice;
361  Win32kCallbacks.Callout = VideoPortCallout;
362  // Reset the data being returned prior to the call.
363  Win32kCallbacks.bACPI = FALSE;
364  Win32kCallbacks.pPhysDeviceObject = NULL;
365  Win32kCallbacks.DualviewFlags = 0;
366  Status = (NTSTATUS)EngDeviceIoControl((HANDLE)pDeviceObject,
368  &Win32kCallbacks,
369  sizeof(Win32kCallbacks),
370  &Win32kCallbacks,
371  sizeof(Win32kCallbacks),
372  &ulReturn);
373  if (Status != ERROR_SUCCESS)
374  {
375  ERR("EngDeviceIoControl(0x%p, IOCTL_VIDEO_INIT_WIN32K_CALLBACKS) failed, Status 0x%lx\n",
377  }
378  // TODO: Set flags according to the results.
379  // if (Win32kCallbacks.bACPI)
380  // if (Win32kCallbacks.DualviewFlags & ???)
381  // Win32kCallbacks.pPhysDeviceObject;
382 
383  /* Copy the device name */
384  RtlStringCbCopyNW(pGraphicsDevice->szNtDeviceName,
385  sizeof(pGraphicsDevice->szNtDeviceName),
386  pustrDeviceName->Buffer,
387  pustrDeviceName->Length);
388 
389  /* Create a Win32 device name (FIXME: virtual devices!) */
390  RtlStringCbPrintfW(pGraphicsDevice->szWinDeviceName,
391  sizeof(pGraphicsDevice->szWinDeviceName),
392  L"\\\\.\\DISPLAY%d",
393  (int)giDevNum);
394 
395  /* Allocate a buffer for the strings */
396  cj = pustrDiplayDrivers->Length + pustrDescription->Length + sizeof(WCHAR);
398  if (!pwsz)
399  {
400  ERR("Could not allocate string buffer\n");
401  ASSERT(FALSE); // FIXME
402  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
403  return NULL;
404  }
405 
406  /* Copy the display driver names */
407  pGraphicsDevice->pDiplayDrivers = pwsz;
408  RtlCopyMemory(pGraphicsDevice->pDiplayDrivers,
409  pustrDiplayDrivers->Buffer,
410  pustrDiplayDrivers->Length);
411 
412  /* Copy the description */
413  pGraphicsDevice->pwszDescription = pwsz + pustrDiplayDrivers->Length / sizeof(WCHAR);
414  RtlCopyMemory(pGraphicsDevice->pwszDescription,
415  pustrDescription->Buffer,
416  pustrDescription->Length);
417  pGraphicsDevice->pwszDescription[pustrDescription->Length/sizeof(WCHAR)] = 0;
418 
419  /* Initialize the pdevmodeInfo list and default index */
420  pGraphicsDevice->pdevmodeInfo = NULL;
421  pGraphicsDevice->iDefaultMode = 0;
422  pGraphicsDevice->iCurrentMode = 0;
423 
424  // FIXME: initialize state flags
425  pGraphicsDevice->StateFlags = 0;
426 
427  /* Create the mode list */
428  pGraphicsDevice->pDevModeList = NULL;
429  if (!EngpPopulateDeviceModeList(pGraphicsDevice, pdmDefault))
430  {
431  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
432  return NULL;
433  }
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,
473 {
474  UNICODE_STRING ustrCurrent;
475  PGRAPHICS_DEVICE pGraphicsDevice;
476  ULONG i;
477  TRACE("EngpFindGraphicsDevice('%wZ', %lu, 0x%lx)\n",
478  pustrDevice, iDevNum, dwFlags);
479 
480  /* Lock list */
482 
483  if (pustrDevice && pustrDevice->Buffer)
484  {
485  /* Loop through the list of devices */
486  for (pGraphicsDevice = gpGraphicsDeviceFirst;
487  pGraphicsDevice;
488  pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice)
489  {
490  /* Compare the device name */
491  RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);
492  if (RtlEqualUnicodeString(&ustrCurrent, pustrDevice, FALSE))
493  {
494  break;
495  }
496  }
497  }
498  else
499  {
500  /* Loop through the list of devices */
501  for (pGraphicsDevice = gpGraphicsDeviceFirst, i = 0;
502  pGraphicsDevice && i < iDevNum;
503  pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice, i++);
504  }
505 
506  /* Unlock list */
508 
509  return pGraphicsDevice;
510 }
511 
512 static
513 NTSTATUS
515  _In_ PFILE_OBJECT pFileObject,
516  _In_ ULONG ulMajorFunction,
517  _In_reads_(nBufferSize) PVOID lpBuffer,
518  _In_ SIZE_T nBufferSize,
519  _In_ ULONGLONG ullStartOffset,
520  _Out_ PULONG_PTR lpInformation)
521 {
523  KEVENT Event;
524  PIRP pIrp;
527  LARGE_INTEGER liStartOffset;
528 
529  /* Get corresponding device object */
531  if (!pDeviceObject)
532  {
534  }
535 
536  /* Initialize an event */
538 
539  /* Build IRP */
540  liStartOffset.QuadPart = ullStartOffset;
541  pIrp = IoBuildSynchronousFsdRequest(ulMajorFunction,
543  lpBuffer,
544  (ULONG)nBufferSize,
545  &liStartOffset,
546  &Event,
547  &Iosb);
548  if (!pIrp)
549  {
551  }
552 
553  /* Call the driver */
555 
556  /* Wait if neccessary */
557  if (STATUS_PENDING == Status)
558  {
560  Status = Iosb.Status;
561  }
562 
563  /* Return information to the caller about the operation. */
564  *lpInformation = Iosb.Information;
565 
566  /* Return NTSTATUS */
567  return Status;
568 }
569 
570 VOID
571 APIENTRY
573  _In_ PFILE_OBJECT pFileObject,
576  _Out_ PSIZE_T lpBytesWritten)
577 {
579 
580  status = EngpFileIoRequest(pFileObject,
581  IRP_MJ_WRITE,
582  lpBuffer,
583  nLength,
584  0,
585  lpBytesWritten);
586  if (!NT_SUCCESS(status))
587  {
588  *lpBytesWritten = 0;
589  }
590 }
591 
592 _Success_(return>=0)
593 NTSTATUS
594 APIENTRY
595 EngFileIoControl(
596  _In_ PFILE_OBJECT pFileObject,
598  _In_reads_(nInBufferSize) PVOID lpInBuffer,
599  _In_ SIZE_T nInBufferSize,
600  _Out_writes_(nOutBufferSize) PVOID lpOutBuffer,
601  _In_ SIZE_T nOutBufferSize,
602  _Out_ PULONG_PTR lpInformation)
603 {
605  KEVENT Event;
606  PIRP pIrp;
609 
610  /* Get corresponding device object */
612  if (!pDeviceObject)
613  {
615  }
616 
617  /* Initialize an event */
619 
620  /* Build IO control IRP */
623  lpInBuffer,
624  (ULONG)nInBufferSize,
625  lpOutBuffer,
626  (ULONG)nOutBufferSize,
627  FALSE,
628  &Event,
629  &Iosb);
630  if (!pIrp)
631  {
633  }
634 
635  /* Call the driver */
637 
638  /* Wait if neccessary */
639  if (Status == STATUS_PENDING)
640  {
642  Status = Iosb.Status;
643  }
644 
645  /* Return information to the caller about the operation. */
646  *lpInformation = Iosb.Information;
647 
648  /* This function returns NTSTATUS */
649  return Status;
650 }
651 
652 /*
653  * @implemented
654  */
655 _Success_(return==0)
656 DWORD
657 APIENTRY
658 EngDeviceIoControl(
659  _In_ HANDLE hDevice,
666 {
667  PIRP Irp;
669  KEVENT Event;
672 
673  TRACE("EngDeviceIoControl() called\n");
674 
675  if (!hDevice)
676  {
677  return ERROR_INVALID_HANDLE;
678  }
679 
681 
682  DeviceObject = (PDEVICE_OBJECT) hDevice;
683 
685  DeviceObject,
686  lpInBuffer,
688  lpOutBuffer,
690  FALSE,
691  &Event,
692  &Iosb);
693  if (!Irp) return ERROR_NOT_ENOUGH_MEMORY;
694 
696 
697  if (Status == STATUS_PENDING)
698  {
700  Status = Iosb.Status;
701  }
702 
703  TRACE("EngDeviceIoControl(): Returning %X/%X\n", Iosb.Status,
704  Iosb.Information);
705 
706  /* Return information to the caller about the operation. */
707  *lpBytesReturned = (DWORD)Iosb.Information;
708 
709  /* Convert NT status values to win32 error codes. */
710  switch (Status)
711  {
714 
716  return ERROR_MORE_DATA;
717 
719  return ERROR_INVALID_FUNCTION;
720 
723 
726 
728  return ERROR_DEV_NOT_EXIST;
729 
730  case STATUS_PENDING:
731  return ERROR_IO_PENDING;
732  }
733 
734  return Status;
735 }
736 
737 /* EOF */
BOOLEAN EngpPopulateDeviceModeList(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW pdmDefault)
Definition: device.c:125
signed char * PCHAR
Definition: retypes.h:7
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
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
_In_ ULONG cj
Definition: winddi.h:3540
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ DWORD _In_reads_(nInBufferSize)
Definition: device.c:598
struct _devicemodeW * PDEVMODEW
#define _In_opt_
Definition: ms_sal.h:309
static PGRAPHICS_DEVICE gpGraphicsDeviceLast
Definition: device.c:19
#define _Inout_
Definition: ms_sal.h:378
#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
VIDEO_WIN32K_CALLBACKS_PARAMS_TYPE CalloutType
Definition: ntddvdeo.h:250
PDEVMODEINFO NTAPI LDEVOBJ_pdmiGetModes(_In_ PLDEVOBJ pldev, _In_ HANDLE hDriver)
Definition: ldevobj.c:116
_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
PPDEVOBJ gppdevPrimary
Definition: pdevobj.c:13
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
WORD dmDriverExtra
Definition: wingdi.h:1621
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
FxIrp * pIrp
#define swprintf
Definition: precomp.h:40
DWORD dmBitsPerPel
Definition: wingdi.h:1647
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:198
PLDEVOBJ NTAPI EngLoadImageEx(_In_z_ LPWSTR pwszDriverName, _In_ ULONG ldevtype)
Definition: ldevobj.c:328
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
PGRAPHICS_DEVICE NTAPI EngpRegisterGraphicsDevice(_In_ PUNICODE_STRING pustrDeviceName, _In_ PUNICODE_STRING pustrDiplayDrivers, _In_ PUNICODE_STRING pustrDescription, _In_ PDEVMODEW pdmDefault)
Definition: device.c:316
return STATUS_NOT_IMPLEMENTED
PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice(_In_opt_ PUNICODE_STRING pustrDevice, _In_ ULONG iDevNum, _In_ DWORD dwFlags)
Definition: device.c:469
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
ULONG cbdevmode
Definition: pdevobj.h:46
_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:256
static PGRAPHICS_DEVICE gpGraphicsDeviceFirst
Definition: device.c:18
unsigned char BOOLEAN
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
#define _In_
Definition: ms_sal.h:308
BOOL FASTCALL IntPaintDesktop(HDC hDC)
Definition: desktop.c:1795
switch(r->id)
Definition: btrfs.c:2980
_In_ DWORD dwIoControlCode
Definition: device.c:597
#define FILE_WRITE_DATA
Definition: nt_native.h:631
DEVMODEW adevmode[1]
Definition: pdevobj.h:47
#define _Out_writes_bytes_opt_(size)
Definition: ms_sal.h:351
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
return Iosb
Definition: create.c:4402
ULONG iCurrentMode
Definition: pdevobj.h:78
#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
struct _DEVMODEINFO * pdmiNext
Definition: pdevobj.h:44
OUT HANDLE pPhysDeviceObject
Definition: ntddvdeo.h:265
WORD dmSize
Definition: wingdi.h:1620
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
* PFILE_OBJECT
Definition: iotypes.h:1998
WCHAR dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1617
DWORD dmPelsWidth
Definition: wingdi.h:1648
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
HDC hdc
Definition: main.c:9
#define NTSTATUS
Definition: precomp.h:20
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define GDITAG_DRVSUP
Definition: tags.h:76
#define VOID
Definition: acefi.h:82
struct _VIDEO_WIN32K_CALLBACKS_PARAMS * PVIDEO_WIN32K_CALLBACKS_PARAMS
#define NOTHING
Definition: env_spec_w32.h:461
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define GDITAG_GDEVICE
Definition: tags.h:98
OUT ULONG DualviewFlags
Definition: ntddvdeo.h:266
#define ERR(fmt,...)
Definition: debug.h:110
ULONG_PTR SIZE_T
Definition: typedefs.h:80
DWORD dmDisplayFrequency
Definition: wingdi.h:1654
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
HDC FASTCALL IntGdiCreateDC(PUNICODE_STRING Driver, PUNICODE_STRING pustrDevice, PVOID pUMdhpdev, CONST PDEVMODEW pdmInit, BOOL CreateAsIC)
Definition: dclife.c:1040
#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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
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
DWORD dmPelsHeight
Definition: wingdi.h:1649
#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
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
HDC ScreenDeviceContext
Definition: desktop.c:36
VOID APIENTRY EngFileWrite(_In_ PFILE_OBJECT pFileObject, _In_reads_(nLength) PVOID lpBuffer, _In_ SIZE_T nLength, _Out_ PSIZE_T lpBytesWritten)
Definition: device.c:572
#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:514
ULONG iDefaultMode
Definition: pdevobj.h:77
PFILE_OBJECT FileObject
Definition: pdevobj.h:75
#define APIENTRY
Definition: api.h:79
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