ReactOS 0.4.16-dev-297-gc569aee
device.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TAG_GDEV   'gdev'
 

Functions

VOID NTAPI PDEVOBJ_vRefreshModeList (PPDEVOBJ ppdev)
 
VOID APIENTRY EngFileWrite (_In_ PFILE_OBJECT pFileObject, _In_reads_(nLength) PVOID lpBuffer, _In_ SIZE_T nLength, _Out_ PSIZE_T lpBytesWritten)
 
PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice (_In_opt_ PUNICODE_STRING pustrDevice, _In_ ULONG iDevNum)
 
PGRAPHICS_DEVICE NTAPI EngpRegisterGraphicsDevice (_In_ PUNICODE_STRING pustrDeviceName, _In_ PUNICODE_STRING pustrDiplayDrivers, _In_ PUNICODE_STRING pustrDescription)
 
NTSTATUS EngpUpdateGraphicsDeviceList (VOID)
 
NTSTATUS EngpGetDisplayDriverParameters (_In_ PGRAPHICS_DEVICE pGraphicsDevice, _Out_ PDEVMODEW pdm)
 
DWORD EngpGetDisplayDriverAccelerationLevel (_In_ PGRAPHICS_DEVICE pGraphicsDevice)
 
NTSTATUS NTAPI InitDeviceImpl (VOID)
 

Macro Definition Documentation

◆ TAG_GDEV

#define TAG_GDEV   'gdev'

Definition at line 4 of file device.h.

Function Documentation

◆ EngFileWrite()

VOID APIENTRY EngFileWrite ( _In_ PFILE_OBJECT  pFileObject,
_In_reads_(nLength) PVOID  lpBuffer,
_In_ SIZE_T  nLength,
_Out_ PSIZE_T  lpBytesWritten 
)

Definition at line 754 of file device.c.

759{
761
762 status = EngpFileIoRequest(pFileObject,
764 lpBuffer,
765 nLength,
766 0,
767 lpBytesWritten);
768 if (!NT_SUCCESS(status))
769 {
770 *lpBytesWritten = 0;
771 }
772}
LONG NTSTATUS
Definition: precomp.h:26
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
Definition: ps.c:97
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:696
_In_ DWORD nLength
Definition: wincon.h:473

◆ EngpFindGraphicsDevice()

PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice ( _In_opt_ PUNICODE_STRING  pustrDevice,
_In_ ULONG  iDevNum 
)

Definition at line 641 of file device.c.

644{
645 UNICODE_STRING ustrCurrent;
646 PGRAPHICS_DEVICE pGraphicsDevice;
647 ULONG i;
648 TRACE("EngpFindGraphicsDevice('%wZ', %lu)\n",
649 pustrDevice, iDevNum);
650
651 /* Lock list */
653
654 if (pustrDevice && pustrDevice->Buffer)
655 {
656 /* Find specified video adapter by name */
657 for (pGraphicsDevice = gpGraphicsDeviceFirst;
658 pGraphicsDevice;
659 pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice)
660 {
661 /* Compare the device name */
662 RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);
663 if (RtlEqualUnicodeString(&ustrCurrent, pustrDevice, FALSE))
664 {
665 break;
666 }
667 }
668
669 if (pGraphicsDevice)
670 {
671 /* Validate selected monitor number */
672#if 0
673 if (iDevNum >= pGraphicsDevice->dwMonCnt)
674 pGraphicsDevice = NULL;
675#else
676 /* FIXME: dwMonCnt not initialized, see EngpRegisterGraphicsDevice */
677#endif
678 }
679 }
680 else
681 {
682 /* Select video adapter by device number */
683 for (pGraphicsDevice = gpGraphicsDeviceFirst, i = 0;
684 pGraphicsDevice && i < iDevNum;
685 pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice, i++);
686 }
687
688 /* Unlock list */
690
691 return pGraphicsDevice;
692}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
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
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR szWinDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:60
DWORD dwMonCnt
Definition: pdevobj.h:73
struct _GRAPHICS_DEVICE * pNextGraphicsDevice
Definition: pdevobj.h:61
uint32_t ULONG
Definition: typedefs.h:59
static PGRAPHICS_DEVICE gpGraphicsDeviceFirst
Definition: device.c:18
static HSEMAPHORE ghsemGraphicsDeviceList
Definition: device.c:20
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)

Referenced by co_IntInitializeDesktopGraphics(), EngpUpdateGraphicsDeviceList(), MDEVOBJ_Create(), PDEVOBJ_lChangeDisplaySettings(), UserEnumDisplayDevices(), and UserEnumDisplaySettings().

◆ EngpGetDisplayDriverAccelerationLevel()

DWORD EngpGetDisplayDriverAccelerationLevel ( _In_ PGRAPHICS_DEVICE  pGraphicsDevice)

Definition at line 400 of file device.c.

402{
403 HKEY hKey;
404 DWORD dwAccelerationLevel = 0;
405 RTL_QUERY_REGISTRY_TABLE DisplaySettingsTable[] =
406 {
407 {
408 NULL,
410 L"Acceleration.Level",
411 &dwAccelerationLevel,
412 REG_NONE, NULL, 0
413 },
414 {0}
415 };
416
417 hKey = EngpGetRegistryHandleFromDeviceMap(pGraphicsDevice);
418 if (!hKey)
419 return 0;
420
422 (PWSTR)hKey,
423 DisplaySettingsTable,
424 NULL,
425 NULL);
426 ZwClose(hKey);
427
428 return dwAccelerationLevel;
429}
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
#define REG_NONE
Definition: nt_native.h:1492
#define RTL_REGISTRY_HANDLE
Definition: nt_native.h:168
#define L(x)
Definition: ntvdm.h:50
uint16_t * PWSTR
Definition: typedefs.h:56
static HKEY EngpGetRegistryHandleFromDeviceMap(_In_ PGRAPHICS_DEVICE pGraphicsDevice)
Definition: device.c:316

Referenced by MDEVOBJ_Create().

◆ EngpGetDisplayDriverParameters()

NTSTATUS EngpGetDisplayDriverParameters ( _In_ PGRAPHICS_DEVICE  pGraphicsDevice,
_Out_ PDEVMODEW  pdm 
)

Definition at line 354 of file device.c.

357{
358 HKEY hKey;
360 RTL_QUERY_REGISTRY_TABLE DisplaySettingsTable[] =
361 {
362#define READ(field, str) \
363 { \
364 NULL, \
365 RTL_QUERY_REGISTRY_DIRECT, \
366 L ##str, \
367 &pdm->field, \
368 REG_NONE, NULL, 0 \
369 },
370 READ(dmBitsPerPel, "DefaultSettings.BitsPerPel")
371 READ(dmPelsWidth, "DefaultSettings.XResolution")
372 READ(dmPelsHeight, "DefaultSettings.YResolution")
373 READ(dmDisplayFlags, "DefaultSettings.Flags")
374 READ(dmDisplayFrequency, "DefaultSettings.VRefresh")
375 READ(dmPanningWidth, "DefaultSettings.XPanning")
376 READ(dmPanningHeight, "DefaultSettings.YPanning")
377 READ(dmDisplayOrientation, "DefaultSettings.Orientation")
378 READ(dmDisplayFixedOutput, "DefaultSettings.FixedOutput")
379 READ(dmPosition.x, "Attach.RelativeX")
380 READ(dmPosition.y, "Attach.RelativeY")
381#undef READ
382 {0}
383 };
384
385 hKey = EngpGetRegistryHandleFromDeviceMap(pGraphicsDevice);
386 if (!hKey)
387 return STATUS_UNSUCCESSFUL;
388
390 (PWSTR)hKey,
391 DisplaySettingsTable,
392 NULL,
393 NULL);
394
395 ZwClose(hKey);
396 return Status;
397}
Status
Definition: gdiplustypes.h:25
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define READ(field, str)
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by LDEVOBJ_bProbeAndCaptureDevmode().

◆ EngpRegisterGraphicsDevice()

PGRAPHICS_DEVICE NTAPI EngpRegisterGraphicsDevice ( _In_ PUNICODE_STRING  pustrDeviceName,
_In_ PUNICODE_STRING  pustrDiplayDrivers,
_In_ PUNICODE_STRING  pustrDescription 
)

Definition at line 497 of file device.c.

501{
502 PGRAPHICS_DEVICE pGraphicsDevice;
504 PFILE_OBJECT pFileObject;
506 VIDEO_WIN32K_CALLBACKS Win32kCallbacks;
507 ULONG ulReturn;
508 PWSTR pwsz;
509 ULONG cj;
510
511 TRACE("EngpRegisterGraphicsDevice(%wZ)\n", pustrDeviceName);
512
513 /* Allocate a GRAPHICS_DEVICE structure */
514 pGraphicsDevice = ExAllocatePoolZero(PagedPool,
515 sizeof(GRAPHICS_DEVICE),
517 if (!pGraphicsDevice)
518 {
519 ERR("ExAllocatePoolWithTag failed\n");
520 return NULL;
521 }
522
523 /* Try to open and enable the device */
524 Status = IoGetDeviceObjectPointer(pustrDeviceName,
526 &pFileObject,
528 if (!NT_SUCCESS(Status))
529 {
530 ERR("Could not open device %wZ, 0x%lx\n", pustrDeviceName, Status);
531 ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
532 return NULL;
533 }
534
535 /* Copy the device and file object pointers */
536 pGraphicsDevice->DeviceObject = pDeviceObject;
537 pGraphicsDevice->FileObject = pFileObject;
538
539 /* Initialize and register the device with videoprt for Win32k callbacks */
540 Win32kCallbacks.PhysDisp = pGraphicsDevice;
541 Win32kCallbacks.Callout = VideoPortCallout;
542 // Reset the data being returned prior to the call.
543 Win32kCallbacks.bACPI = FALSE;
544 Win32kCallbacks.pPhysDeviceObject = NULL;
545 Win32kCallbacks.DualviewFlags = 0;
546 Status = (NTSTATUS)EngDeviceIoControl((HANDLE)pDeviceObject,
548 &Win32kCallbacks,
549 sizeof(Win32kCallbacks),
550 &Win32kCallbacks,
551 sizeof(Win32kCallbacks),
552 &ulReturn);
553 if (Status != ERROR_SUCCESS)
554 {
555 ERR("EngDeviceIoControl(0x%p, IOCTL_VIDEO_INIT_WIN32K_CALLBACKS) failed, Status 0x%lx\n",
557 }
558 // TODO: Set flags according to the results.
559 // if (Win32kCallbacks.bACPI)
560 // if (Win32kCallbacks.DualviewFlags & ???)
561 pGraphicsDevice->PhysDeviceHandle = Win32kCallbacks.pPhysDeviceObject;
562
563 /* FIXME: Enumerate children monitor devices for this video adapter
564 *
565 * - Force the adapter to re-enumerate its monitors:
566 * IoSynchronousInvalidateDeviceRelations(pdo, BusRelations)
567 *
568 * - Retrieve all monitor PDOs from VideoPrt:
569 * EngDeviceIoControl(0x%p, IOCTL_VIDEO_ENUM_MONITOR_PDO)
570 *
571 * - Initialize these fields and structures accordingly:
572 * pGraphicsDevice->dwMonCnt
573 * pGraphicsDevice->pvMonDev[0..dwMonCnt-1]
574 */
575
576 /* Copy the device name */
577 RtlStringCbCopyNW(pGraphicsDevice->szNtDeviceName,
578 sizeof(pGraphicsDevice->szNtDeviceName),
579 pustrDeviceName->Buffer,
580 pustrDeviceName->Length);
581
582 /* Create a Win32 device name (FIXME: virtual devices!) */
583 RtlStringCbPrintfW(pGraphicsDevice->szWinDeviceName,
584 sizeof(pGraphicsDevice->szWinDeviceName),
585 L"\\\\.\\DISPLAY%d",
586 (int)giDevNum);
587
588 /* Allocate a buffer for the strings */
589 cj = pustrDiplayDrivers->Length + pustrDescription->Length + sizeof(WCHAR);
591 if (!pwsz)
592 {
593 ERR("Could not allocate string buffer\n");
594 ASSERT(FALSE); // FIXME
595 ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
596 return NULL;
597 }
598
599 /* Copy the display driver names */
600 pGraphicsDevice->pDiplayDrivers = pwsz;
601 RtlCopyMemory(pGraphicsDevice->pDiplayDrivers,
602 pustrDiplayDrivers->Buffer,
603 pustrDiplayDrivers->Length);
604
605 /* Copy the description */
606 pGraphicsDevice->pwszDescription = pwsz + pustrDiplayDrivers->Length / sizeof(WCHAR);
607 RtlCopyMemory(pGraphicsDevice->pwszDescription,
608 pustrDescription->Buffer,
609 pustrDescription->Length);
610 pGraphicsDevice->pwszDescription[pustrDescription->Length/sizeof(WCHAR)] = 0;
611
612 /* Lock loader */
614
615 /* Insert the device into the global list */
616 EngpLinkGraphicsDevice(pGraphicsDevice);
617
618 /* Increment the device number */
619 giDevNum++;
620
621 /* Unlock loader */
623 TRACE("Prepared %lu modes for %ls\n", pGraphicsDevice->cDevModes, pGraphicsDevice->pwszDescription);
624
625 /* HACK: already in graphic mode; display wallpaper on this new display */
627 {
628 UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
629 UNICODE_STRING DisplayName;
630 HDC hdc;
631 RtlInitUnicodeString(&DisplayName, pGraphicsDevice->szWinDeviceName);
632 hdc = IntGdiCreateDC(&DriverName, &DisplayName, NULL, NULL, FALSE);
634 }
635
636 return pGraphicsDevice;
637}
#define ERR(fmt,...)
Definition: precomp.h:57
HDC FASTCALL IntGdiCreateDC(PUNICODE_STRING Driver, PUNICODE_STRING pustrDevice, PVOID pUMdhpdev, CONST PDEVMODEW pdmInit, BOOL CreateAsIC)
Definition: dclife.c:1040
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NTSTATUS
Definition: precomp.h:21
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
HDC hdc
Definition: main.c:9
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
static HDC
Definition: imagelist.c:88
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:131
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
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
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
LPWSTR pDiplayDrivers
Definition: pdevobj.h:71
PFILE_OBJECT FileObject
Definition: pdevobj.h:75
WCHAR szNtDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:59
LPWSTR pwszDescription
Definition: pdevobj.h:72
ULONG cDevModes
Definition: pdevobj.h:69
PDEVICE_OBJECT DeviceObject
Definition: pdevobj.h:63
PDEVICE_OBJECT PhysDeviceHandle
Definition: pdevobj.h:64
OUT ULONG DualviewFlags
Definition: ntddvdeo.h:335
IN PVIDEO_WIN32K_CALLOUT Callout
Definition: ntddvdeo.h:332
OUT HANDLE pPhysDeviceObject
Definition: ntddvdeo.h:334
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
static ULONG giDevNum
Definition: device.c:21
VOID NTAPI VideoPortCallout(_In_ PVOID Params)
Definition: device.c:437
HDC ScreenDeviceContext
Definition: desktop.c:53
BOOL FASTCALL IntPaintDesktop(HDC hDC)
Definition: desktop.c:1852
#define GDITAG_DRVSUP
Definition: tags.h:77
#define GDITAG_GDEVICE
Definition: tags.h:99
_In_ ULONG cj
Definition: winddi.h:3540
* PFILE_OBJECT
Definition: iotypes.h:1998
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by InitDisplayDriver().

◆ EngpUpdateGraphicsDeviceList()

NTSTATUS EngpUpdateGraphicsDeviceList ( VOID  )

Definition at line 174 of file device.c.

175{
176 ULONG iDevNum, iVGACompatible = -1, ulMaxObjectNumber = 0;
177 WCHAR awcDeviceName[20], awcWinDeviceName[20];
178 UNICODE_STRING ustrDeviceName;
179 WCHAR awcBuffer[256];
181 PGRAPHICS_DEVICE pGraphicsDevice;
182 BOOLEAN bFoundNewDevice = FALSE;
183 ULONG cbValue;
184 HKEY hkey;
185
186 /* Open the key for the adapters */
187 Status = RegOpenKey(L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP\\VIDEO", &hkey);
188 if (!NT_SUCCESS(Status))
189 {
190 ERR("Could not open HARDWARE\\DEVICEMAP\\VIDEO registry key:0x%lx\n", Status);
191 return Status;
192 }
193
194 /* Read the name of the VGA adapter */
195 cbValue = sizeof(awcDeviceName);
196 Status = RegQueryValue(hkey, L"VgaCompatible", REG_SZ, awcDeviceName, &cbValue);
197 if (NT_SUCCESS(Status))
198 {
199 iVGACompatible = _wtoi(&awcDeviceName[sizeof("\\Device\\Video")-1]);
200 ERR("VGA adapter = %lu\n", iVGACompatible);
201 }
202
203 /* Get the maximum number of adapters */
204 if (!RegReadDWORD(hkey, L"MaxObjectNumber", &ulMaxObjectNumber))
205 {
206 ERR("Could not read MaxObjectNumber, defaulting to 0.\n");
207 }
208
209 TRACE("Found %lu devices\n", ulMaxObjectNumber + 1);
210
211 /* Loop through all adapters */
212 for (iDevNum = 0; iDevNum <= ulMaxObjectNumber; iDevNum++)
213 {
214 /* Create the adapter's key name */
215 swprintf(awcDeviceName, L"\\Device\\Video%lu", iDevNum);
216
217 /* Create the display device name */
218 swprintf(awcWinDeviceName, L"\\\\.\\DISPLAY%lu", iDevNum + 1);
219 RtlInitUnicodeString(&ustrDeviceName, awcWinDeviceName);
220
221 /* Check if the device exists already */
222 pGraphicsDevice = EngpFindGraphicsDevice(&ustrDeviceName, iDevNum);
223 if (pGraphicsDevice != NULL)
224 {
225 continue;
226 }
227
228 /* Read the reg key name */
229 cbValue = sizeof(awcBuffer);
230 Status = RegQueryValue(hkey, awcDeviceName, REG_SZ, awcBuffer, &cbValue);
231 if (!NT_SUCCESS(Status))
232 {
233 ERR("failed to query the registry path:0x%lx\n", Status);
234 continue;
235 }
236
237 /* Initialize the driver for this device */
238 pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer);
239 if (!pGraphicsDevice) continue;
240
241 /* Check if this is a VGA compatible adapter */
242 if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
243 {
244 /* Save this as the VGA adapter */
246 {
247 gpVgaGraphicsDevice = pGraphicsDevice;
248 TRACE("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
249 }
250 }
251 bFoundNewDevice = TRUE;
252
253 /* Set the first one as primary device */
255 {
256 gpPrimaryGraphicsDevice = pGraphicsDevice;
257 TRACE("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice);
258 }
259 }
260
261 /* Close the device map registry key */
262 ZwClose(hkey);
263
264 /* Can we link VGA device to primary device? */
269 {
270 /* Yes. Remove VGA device from global list, and attach it to primary device */
271 TRACE("Linking VGA device %S to primary device %S\n", gpVgaGraphicsDevice->szNtDeviceName, gpPrimaryGraphicsDevice->szNtDeviceName);
272 EngpUnlinkGraphicsDevice(gpVgaGraphicsDevice);
274 }
275
276 if (bFoundNewDevice && gbBaseVideo)
277 {
278 PGRAPHICS_DEVICE pToDelete;
279
280 /* Lock list */
282
283 /* Remove every device from linked list, except base-video one */
284 pGraphicsDevice = gpGraphicsDeviceFirst;
285 while (pGraphicsDevice)
286 {
287 if (!EngpHasVgaDriver(pGraphicsDevice))
288 {
289 /* Not base-video device. Remove it */
290 pToDelete = pGraphicsDevice;
291 TRACE("Removing non-base-video device %S (%S)\n", pToDelete->szWinDeviceName, pToDelete->szNtDeviceName);
292
293 EngpUnlinkGraphicsDevice(pGraphicsDevice);
294 pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice;
295
296 /* Free memory */
299 }
300 else
301 {
302 pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice;
303 }
304 }
305
306 /* Unlock list */
308 }
309
310 return STATUS_SUCCESS;
311}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define swprintf
Definition: precomp.h:40
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define STATUS_SUCCESS
Definition: shellext.h:65
DWORD StateFlags
Definition: pdevobj.h:66
struct _GRAPHICS_DEVICE * pVgaDevice
Definition: pdevobj.h:62
static BOOLEAN EngpHasVgaDriver(_In_ PGRAPHICS_DEVICE pGraphicsDevice)
Definition: device.c:37
PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice(_In_opt_ PUNICODE_STRING pustrDevice, _In_ ULONG iDevNum)
Definition: device.c:641
static PGRAPHICS_DEVICE gpPrimaryGraphicsDevice
Definition: device.c:15
static PGRAPHICS_DEVICE gpVgaGraphicsDevice
Definition: device.c:16
BOOL NTAPI RegReadDWORD(HKEY hkey, PCWSTR pwszValue, PDWORD pdwData)
Definition: registry.c:149
BOOL gbBaseVideo
Definition: display.c:12
PGRAPHICS_DEVICE NTAPI InitDisplayDriver(IN PWSTR pwszDeviceName, IN PWSTR pwszRegKey)
Definition: display.c:66
#define DISPLAY_DEVICE_VGA_COMPATIBLE
Definition: wingdi.h:1400
#define RegOpenKey
Definition: winreg.h:519
#define RegQueryValue
Definition: winreg.h:523

Referenced by InitVideo(), and UserEnumDisplayDevices().

◆ InitDeviceImpl()

NTSTATUS NTAPI InitDeviceImpl ( VOID  )

Definition at line 26 of file device.c.

27{
31
32 return STATUS_SUCCESS;
33}
HSEMAPHORE WINAPI EngCreateSemaphore(VOID)
Definition: eng.c:75
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by DriverEntry().

◆ PDEVOBJ_vRefreshModeList()

VOID NTAPI PDEVOBJ_vRefreshModeList ( PPDEVOBJ  ppdev)

Definition at line 436 of file pdevobj.c.

438{
439 PGRAPHICS_DEVICE pGraphicsDevice;
440 PDEVMODEINFO pdminfo, pdmiNext;
441
442 /* Lock the PDEV */
444
445 pGraphicsDevice = ppdev->pGraphicsDevice;
446
447 /* Clear out the modes */
448 for (pdminfo = pGraphicsDevice->pdevmodeInfo;
449 pdminfo;
450 pdminfo = pdmiNext)
451 {
452 pdmiNext = pdminfo->pdmiNext;
454 }
455 pGraphicsDevice->pdevmodeInfo = NULL;
457 pGraphicsDevice->pDevModeList = NULL;
458
459 /* Update available display mode list */
460 LDEVOBJ_bBuildDevmodeList(pGraphicsDevice);
461
462 /* Unlock PDEV */
464}
BOOL LDEVOBJ_bBuildDevmodeList(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice)
Definition: ldevobj.c:565
struct _DEVMODEINFO * pdmiNext
Definition: pdevobj.h:44
PDEVMODEENTRY pDevModeList
Definition: pdevobj.h:70
PDEVMODEINFO pdevmodeInfo
Definition: pdevobj.h:68
PGRAPHICS_DEVICE pGraphicsDevice
Definition: pdevobj.h:127
HSEMAPHORE hsemDevLock
Definition: pdevobj.h:89
#define GDITAG_DEVMODE
Definition: tags.h:73

Referenced by UserEnumDisplaySettings().