ReactOS 0.4.16-dev-297-gc569aee
display.c File Reference
#include <win32k.h>
Include dependency graph for display.c:

Go to the source code of this file.

Macros

#define READ(field, str, flag)
 

Functions

 DBG_DEFAULT_CHANNEL (UserDisplay)
 
VOID RegWriteDisplaySettings (HKEY hkey, PDEVMODEW pdm)
 
VOID RegReadDisplaySettings (HKEY hkey, PDEVMODEW pdm)
 
PGRAPHICS_DEVICE NTAPI InitDisplayDriver (IN PWSTR pwszDeviceName, IN PWSTR pwszRegKey)
 
NTSTATUS NTAPI InitVideo (VOID)
 
VOID UserRefreshDisplay (IN PPDEVOBJ ppdev)
 
NTSTATUS NTAPI UserEnumDisplayDevices (PUNICODE_STRING pustrDevice, DWORD iDevNum, PDISPLAY_DEVICEW pdispdev, DWORD dwFlags)
 
BOOL NTAPI NtUserEnumDisplayDevices (PUNICODE_STRING pustrDevice, DWORD iDevNum, PDISPLAY_DEVICEW pDisplayDevice, DWORD dwFlags)
 
NTSTATUS NTAPI UserEnumCurrentDisplaySettings (PUNICODE_STRING pustrDevice, PDEVMODEW *ppdm)
 
NTSTATUS NTAPI UserEnumDisplaySettings (PUNICODE_STRING pustrDevice, DWORD iModeNum, LPDEVMODEW *ppdm, DWORD dwFlags)
 
NTSTATUS NTAPI UserOpenDisplaySettingsKey (OUT PHKEY phkey, IN PUNICODE_STRING pustrDevice, IN BOOL bGlobal)
 
NTSTATUS NTAPI UserEnumRegistryDisplaySettings (IN PUNICODE_STRING pustrDevice, OUT LPDEVMODEW pdm)
 
NTSTATUS APIENTRY NtUserEnumDisplaySettings (IN PUNICODE_STRING pustrDevice, IN DWORD iModeNum, OUT LPDEVMODEW lpDevMode, IN DWORD dwFlags)
 
VOID UserUpdateFullscreen (DWORD flags)
 
LONG APIENTRY UserChangeDisplaySettings (PUNICODE_STRING pustrDevice, LPDEVMODEW pdm, DWORD flags, LPVOID lParam)
 
VOID UserDisplayNotifyShutdown (PPROCESSINFO ppiCurrent)
 
LONG APIENTRY NtUserChangeDisplaySettings (PUNICODE_STRING pustrDevice, LPDEVMODEW lpDevMode, DWORD dwflags, LPVOID lParam)
 

Variables

BOOL gbBaseVideo = FALSE
 
static PPROCESSINFO gpFullscreen = NULL
 
static const PWCHAR KEY_VIDEO = L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP\\VIDEO"
 

Macro Definition Documentation

◆ READ

#define READ (   field,
  str,
  flag 
)
Value:
if (RegReadDWORD(hkey, L##str, &dwValue)) \
{ \
pdm->field = dwValue; \
pdm->dmFields |= flag; \
}
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 flag
Definition: glfuncs.h:52
#define L(x)
Definition: ntvdm.h:50
const WCHAR * str
BOOL NTAPI RegReadDWORD(HKEY hkey, PCWSTR pwszValue, PDWORD pdwData)
Definition: registry.c:149

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserDisplay  )

◆ InitDisplayDriver()

PGRAPHICS_DEVICE NTAPI InitDisplayDriver ( IN PWSTR  pwszDeviceName,
IN PWSTR  pwszRegKey 
)

Definition at line 66 of file display.c.

69{
70 PGRAPHICS_DEVICE pGraphicsDevice;
71 UNICODE_STRING ustrDeviceName, ustrDisplayDrivers, ustrDescription;
73 WCHAR awcBuffer[128];
74 ULONG cbSize;
75 HKEY hkey;
76 DWORD dwVga;
77
78 TRACE("InitDisplayDriver(%S, %S);\n",
79 pwszDeviceName, pwszRegKey);
80
81 /* Open the driver's registry key */
82 Status = RegOpenKey(pwszRegKey, &hkey);
83 if (!NT_SUCCESS(Status))
84 {
85 ERR("Failed to open registry key: %ls\n", pwszRegKey);
86 return NULL;
87 }
88
89 /* Query the diplay drivers */
90 cbSize = sizeof(awcBuffer) - 10;
91 Status = RegQueryValue(hkey,
92 L"InstalledDisplayDrivers",
94 awcBuffer,
95 &cbSize);
96 if (!NT_SUCCESS(Status))
97 {
98 ERR("Didn't find 'InstalledDisplayDrivers', status = 0x%lx\n", Status);
99 ZwClose(hkey);
100 return NULL;
101 }
102
103 /* Initialize the UNICODE_STRING */
104 ustrDisplayDrivers.Buffer = awcBuffer;
105 ustrDisplayDrivers.MaximumLength = (USHORT)cbSize;
106 ustrDisplayDrivers.Length = (USHORT)cbSize;
107
108 /* Set Buffer for description and size of remaining buffer */
109 ustrDescription.Buffer = awcBuffer + (cbSize / sizeof(WCHAR));
110 cbSize = sizeof(awcBuffer) - cbSize;
111
112 /* Query the device string */
113 Status = RegQueryValue(hkey,
114 L"Device Description",
115 REG_SZ,
116 ustrDescription.Buffer,
117 &cbSize);
118 if (NT_SUCCESS(Status))
119 {
120 ustrDescription.MaximumLength = (USHORT)cbSize;
121 ustrDescription.Length = (USHORT)cbSize;
122 }
123 else
124 {
125 RtlInitUnicodeString(&ustrDescription, L"<unknown>");
126 }
127
128 /* Query if this is a VGA compatible driver */
129 cbSize = sizeof(DWORD);
130 Status = RegQueryValue(hkey, L"VgaCompatible", REG_DWORD, &dwVga, &cbSize);
131 if (!NT_SUCCESS(Status)) dwVga = 0;
132
133 /* Close the registry key */
134 ZwClose(hkey);
135
136 /* Register the device with GDI */
137 RtlInitUnicodeString(&ustrDeviceName, pwszDeviceName);
138 pGraphicsDevice = EngpRegisterGraphicsDevice(&ustrDeviceName,
139 &ustrDisplayDrivers,
140 &ustrDescription);
141 if (pGraphicsDevice && dwVga)
142 {
143 pGraphicsDevice->StateFlags |= DISPLAY_DEVICE_VGA_COMPATIBLE;
144 }
145
146 return pGraphicsDevice;
147}
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
#define REG_SZ
Definition: layer.c:22
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define DWORD
Definition: nt_native.h:44
unsigned short USHORT
Definition: pedump.c:61
#define REG_DWORD
Definition: sdbapi.c:596
#define TRACE(s)
Definition: solgame.cpp:4
DWORD StateFlags
Definition: pdevobj.h:66
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint32_t ULONG
Definition: typedefs.h:59
PGRAPHICS_DEVICE NTAPI EngpRegisterGraphicsDevice(_In_ PUNICODE_STRING pustrDeviceName, _In_ PUNICODE_STRING pustrDiplayDrivers, _In_ PUNICODE_STRING pustrDescription)
Definition: device.c:497
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR pwszDeviceName
Definition: winddi.h:3556
#define DISPLAY_DEVICE_VGA_COMPATIBLE
Definition: wingdi.h:1400
#define RegOpenKey
Definition: winreg.h:519
#define RegQueryValue
Definition: winreg.h:523
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by EngpUpdateGraphicsDeviceList().

◆ InitVideo()

NTSTATUS NTAPI InitVideo ( VOID  )

Definition at line 151 of file display.c.

152{
154 HKEY hkey;
155
156 TRACE("----------------------------- InitVideo() -------------------------------\n");
157
158 /* Check if VGA mode is requested, by finding the special volatile key created by VIDEOPRT */
159 Status = RegOpenKey(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GraphicsDrivers\\BaseVideo", &hkey);
160 if (NT_SUCCESS(Status))
161 ZwClose(hkey);
163 if (gbBaseVideo)
164 ERR("VGA mode requested.\n");
165
166 /* Initialize all display devices */
168 if (!NT_SUCCESS(Status))
169 return Status;
170
172
173 return STATUS_SUCCESS;
174}
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOL InitSysParams()
NTSTATUS EngpUpdateGraphicsDeviceList(VOID)
Definition: device.c:174
BOOL gbBaseVideo
Definition: display.c:12

Referenced by UserInitialize().

◆ NtUserChangeDisplaySettings()

LONG APIENTRY NtUserChangeDisplaySettings ( PUNICODE_STRING  pustrDevice,
LPDEVMODEW  lpDevMode,
DWORD  dwflags,
LPVOID  lParam 
)

Definition at line 930 of file display.c.

935{
936 WCHAR awcDevice[CCHDEVICENAME];
937 UNICODE_STRING ustrDevice;
938 DEVMODEW dmLocal;
939 LONG lRet;
940
941 /* Check arguments */
942 if ((dwflags != CDS_VIDEOPARAMETERS) && (lParam != NULL))
943 {
946 }
947
948 /* Check flags */
950 {
952 }
953
954 if ((dwflags & CDS_RESET) && (dwflags & CDS_NORESET))
955 {
957 }
958
959 /* Copy the device name */
960 if (pustrDevice)
961 {
962 /* Initialize destination string */
963 RtlInitEmptyUnicodeString(&ustrDevice, awcDevice, sizeof(awcDevice));
964
966 {
967 /* Probe the UNICODE_STRING and the buffer */
968 ProbeForRead(pustrDevice, sizeof(UNICODE_STRING), 1);
969 ProbeForRead(pustrDevice->Buffer, pustrDevice->Length, 1);
970
971 /* Copy the string */
972 RtlCopyUnicodeString(&ustrDevice, pustrDevice);
973 }
975 {
976 /* Set and return error */
979 }
981
982 pustrDevice = &ustrDevice;
983 }
984
985 /* Copy devmode */
986 if (lpDevMode)
987 {
989 {
990 /* Probe the size field of the structure */
991 ProbeForRead(lpDevMode, sizeof(dmLocal.dmSize), 1);
992
993 /* Calculate usable size */
994 dmLocal.dmSize = min(sizeof(dmLocal), lpDevMode->dmSize);
995
996 /* Probe and copy the full DEVMODE */
997 ProbeForRead(lpDevMode, dmLocal.dmSize, 1);
998 RtlCopyMemory(&dmLocal, lpDevMode, dmLocal.dmSize);
999 }
1001 {
1002 /* Set and return error */
1005 }
1006 _SEH2_END
1007
1008 /* Check for extra parameters */
1009 if (dmLocal.dmDriverExtra > 0)
1010 {
1011 /* FIXME: TODO */
1012 ERR("lpDevMode->dmDriverExtra is IGNORED!\n");
1013 dmLocal.dmDriverExtra = 0;
1014 }
1015
1016 /* Use the local structure */
1017 lpDevMode = &dmLocal;
1018 }
1019
1020 // FIXME: Copy videoparameters
1021
1022 /* Acquire global USER lock */
1024
1025 /* Call internal function */
1026 lRet = UserChangeDisplaySettings(pustrDevice, lpDevMode, dwflags, NULL);
1027
1028 /* Release lock */
1029 UserLeave();
1030
1031 return lRet;
1032}
LPARAM lParam
Definition: combotst.c:139
#define CCHDEVICENAME
Definition: ddrawi.h:63
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static _In_ DWORD dwflags
Definition: dispmode.c:64
static _In_ DWORD _Inout_ PDEVMODEA lpDevMode
Definition: dispmode.c:77
#define min(a, b)
Definition: monoChain.cc:55
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
long LONG
Definition: pedump.c:60
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
WORD dmSize
Definition: wingdi.h:1568
WORD dmDriverExtra
Definition: wingdi.h:1621
WORD dmSize
Definition: wingdi.h:1620
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
LONG APIENTRY UserChangeDisplaySettings(PUNICODE_STRING pustrDevice, LPDEVMODEW pdm, DWORD flags, LPVOID lParam)
Definition: display.c:700
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
#define CDS_VIDEOPARAMETERS
Definition: winuser.h:186
#define DISP_CHANGE_BADPARAM
Definition: winuser.h:193
#define CDS_UPDATEREGISTRY
Definition: winuser.h:181
#define DISP_CHANGE_BADFLAGS
Definition: winuser.h:192
#define CDS_NORESET
Definition: winuser.h:189
#define CDS_RESET
Definition: winuser.h:187
#define CDS_GLOBAL
Definition: winuser.h:184

Referenced by ChangeDisplaySettingsExA(), and ChangeDisplaySettingsExW().

◆ NtUserEnumDisplayDevices()

BOOL NTAPI NtUserEnumDisplayDevices ( PUNICODE_STRING  pustrDevice,
DWORD  iDevNum,
PDISPLAY_DEVICEW  pDisplayDevice,
DWORD  dwFlags 
)

Definition at line 350 of file display.c.

355{
356 UNICODE_STRING ustrDevice;
357 WCHAR awcDevice[CCHDEVICENAME];
358 DISPLAY_DEVICEW dispdev;
360
361 TRACE("Enter NtUserEnumDisplayDevices(%wZ, %lu)\n",
362 pustrDevice, iDevNum);
363
364 dispdev.cb = sizeof(dispdev);
365
366 if (pustrDevice)
367 {
368 /* Initialize destination string */
369 RtlInitEmptyUnicodeString(&ustrDevice, awcDevice, sizeof(awcDevice));
370
372 {
373 /* Probe the UNICODE_STRING and the buffer */
374 ProbeForRead(pustrDevice, sizeof(UNICODE_STRING), 1);
375 ProbeForRead(pustrDevice->Buffer, pustrDevice->Length, 1);
376
377 /* Copy the string */
378 RtlCopyUnicodeString(&ustrDevice, pustrDevice);
379 }
381 {
382// _SEH2_YIELD(return _SEH2_GetExceptionCode());
384 }
386
387 if (ustrDevice.Length > 0)
388 pustrDevice = &ustrDevice;
389 else
390 pustrDevice = NULL;
391 }
392
393 /* If name is given only iDevNum==0 gives results */
394 if (pustrDevice && iDevNum != 0)
395 return FALSE;
396
397 /* Acquire global USER lock */
399
400 /* Call the internal function */
401 Status = UserEnumDisplayDevices(pustrDevice, iDevNum, &dispdev, dwFlags);
402
403 /* Release lock */
404 UserLeave();
405
406 /* On success copy data to caller */
407 if (NT_SUCCESS(Status))
408 {
409 /* Enter SEH */
411 {
412 /* First probe the cb field */
413 ProbeForWrite(&pDisplayDevice->cb, sizeof(DWORD), 1);
414
415 /* Check the buffer size */
416 if (pDisplayDevice->cb)
417 {
418 /* Probe the output buffer */
419 pDisplayDevice->cb = min(pDisplayDevice->cb, sizeof(dispdev));
420 ProbeForWrite(pDisplayDevice, pDisplayDevice->cb, 1);
421
422 /* Copy as much as the given buffer allows */
423 RtlCopyMemory(pDisplayDevice, &dispdev, pDisplayDevice->cb);
424 }
425 }
427 {
429 }
431 }
432
433 TRACE("Leave NtUserEnumDisplayDevices, Status = 0x%lx\n", Status);
434 /* Return the result */
435// return Status;
436 return NT_SUCCESS(Status); // FIXME
437}
#define FALSE
Definition: types.h:117
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:242
NTSTATUS NTAPI UserEnumDisplayDevices(PUNICODE_STRING pustrDevice, DWORD iDevNum, PDISPLAY_DEVICEW pdispdev, DWORD dwFlags)
Definition: display.c:217
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by EnumDisplayDevicesA(), and EnumDisplayDevicesW().

◆ NtUserEnumDisplaySettings()

NTSTATUS APIENTRY NtUserEnumDisplaySettings ( IN PUNICODE_STRING  pustrDevice,
IN DWORD  iModeNum,
OUT LPDEVMODEW  lpDevMode,
IN DWORD  dwFlags 
)

Definition at line 572 of file display.c.

577{
578 UNICODE_STRING ustrDeviceUser;
579 UNICODE_STRING ustrDevice;
580 WCHAR awcDevice[CCHDEVICENAME];
582 ULONG cbSize, cbExtra;
583 DEVMODEW dmReg, *pdm;
584
585 TRACE("Enter NtUserEnumDisplaySettings(%wZ, %lu, %p, 0x%lx)\n",
586 pustrDevice, iModeNum, lpDevMode, dwFlags);
587
589 {
590 ProbeForRead(lpDevMode, sizeof(DEVMODEW), sizeof(UCHAR));
591
592 cbSize = lpDevMode->dmSize;
593 cbExtra = lpDevMode->dmDriverExtra;
594
595 ProbeForWrite(lpDevMode, cbSize + cbExtra, sizeof(UCHAR));
596 }
598 {
600 }
601 _SEH2_END;
602
603 if (cbSize != sizeof(DEVMODEW))
604 {
606 }
607
608 if (pustrDevice)
609 {
610 /* Initialize destination string */
611 RtlInitEmptyUnicodeString(&ustrDevice, awcDevice, sizeof(awcDevice));
612
614 {
615 /* Probe the UNICODE_STRING and the buffer */
616 ustrDeviceUser = ProbeForReadUnicodeString(pustrDevice);
617
618 if (!ustrDeviceUser.Length || !ustrDeviceUser.Buffer)
620
621 ProbeForRead(ustrDeviceUser.Buffer,
622 ustrDeviceUser.Length,
623 sizeof(UCHAR));
624
625 /* Copy the string */
626 RtlCopyUnicodeString(&ustrDevice, &ustrDeviceUser);
627 }
629 {
631 }
632 _SEH2_END;
633
634 pustrDevice = &ustrDevice;
635 }
636
637 /* Acquire global USER lock */
639
641 {
642 /* Get the registry settings */
643 Status = UserEnumRegistryDisplaySettings(pustrDevice, &dmReg);
644 pdm = &dmReg;
645 pdm->dmSize = sizeof(DEVMODEW);
646 }
648 {
649 /* Get the current settings */
650 Status = UserEnumCurrentDisplaySettings(pustrDevice, &pdm);
651 }
652 else
653 {
654 /* Get specified settings */
655 Status = UserEnumDisplaySettings(pustrDevice, iModeNum, &pdm, dwFlags);
656 }
657
658 /* Release lock */
659 UserLeave();
660
661 /* Did we succeed? */
662 if (NT_SUCCESS(Status))
663 {
664 /* Copy some information back */
666 {
667 /* Output what we got */
668 RtlCopyMemory(lpDevMode, pdm, min(cbSize, pdm->dmSize));
669
670 /* Output private/extra driver data */
671 if (cbExtra > 0 && pdm->dmDriverExtra > 0)
672 {
673 RtlCopyMemory((PCHAR)lpDevMode + cbSize,
674 (PCHAR)pdm + pdm->dmSize,
675 min(cbExtra, pdm->dmDriverExtra));
676 }
677 }
679 {
681 }
682 _SEH2_END;
683 }
684
685 return Status;
686}
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
static _In_ DWORD iModeNum
Definition: dispmode.c:77
#define ExRaiseStatus
Definition: ntoskrnl.h:114
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
#define ProbeForReadUnicodeString(Ptr)
Definition: probe.h:77
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
WORD dmDriverExtra
Definition: wingdi.h:1569
char * PCHAR
Definition: typedefs.h:51
NTSTATUS NTAPI UserEnumRegistryDisplaySettings(IN PUNICODE_STRING pustrDevice, OUT LPDEVMODEW pdm)
Definition: display.c:555
NTSTATUS NTAPI UserEnumDisplaySettings(PUNICODE_STRING pustrDevice, DWORD iModeNum, LPDEVMODEW *ppdm, DWORD dwFlags)
Definition: display.c:464
NTSTATUS NTAPI UserEnumCurrentDisplaySettings(PUNICODE_STRING pustrDevice, PDEVMODEW *ppdm)
Definition: display.c:441
struct _devicemodeW DEVMODEW
#define ENUM_REGISTRY_SETTINGS
Definition: winuser.h:180
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by EnumDisplaySettingsExA(), and EnumDisplaySettingsExW().

◆ RegReadDisplaySettings()

VOID RegReadDisplaySettings ( HKEY  hkey,
PDEVMODEW  pdm 
)

Definition at line 35 of file display.c.

36{
37 DWORD dwValue;
38
39 /* Zero out the structure */
40 RtlZeroMemory(pdm, sizeof(DEVMODEW));
41
42/* Helper macro */
43#define READ(field, str, flag) \
44 if (RegReadDWORD(hkey, L##str, &dwValue)) \
45 { \
46 pdm->field = dwValue; \
47 pdm->dmFields |= flag; \
48 }
49
50 /* Read all present settings */
51 READ(dmBitsPerPel, "DefaultSettings.BitsPerPel", DM_BITSPERPEL);
52 READ(dmPelsWidth, "DefaultSettings.XResolution", DM_PELSWIDTH);
53 READ(dmPelsHeight, "DefaultSettings.YResolution", DM_PELSHEIGHT);
54 READ(dmDisplayFlags, "DefaultSettings.Flags", DM_DISPLAYFLAGS);
55 READ(dmDisplayFrequency, "DefaultSettings.VRefresh", DM_DISPLAYFREQUENCY);
56 READ(dmPanningWidth, "DefaultSettings.XPanning", DM_PANNINGWIDTH);
57 READ(dmPanningHeight, "DefaultSettings.YPanning", DM_PANNINGHEIGHT);
58 READ(dmDisplayOrientation, "DefaultSettings.Orientation", DM_DISPLAYORIENTATION);
59 READ(dmDisplayFixedOutput, "DefaultSettings.FixedOutput", DM_DISPLAYFIXEDOUTPUT);
60 READ(dmPosition.x, "Attach.RelativeX", DM_POSITION);
61 READ(dmPosition.y, "Attach.RelativeY", DM_POSITION);
62}
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define READ(field, str, flag)
#define DM_DISPLAYFREQUENCY
Definition: wingdi.h:1272
#define DM_PELSWIDTH
Definition: wingdi.h:1269
#define DM_POSITION
Definition: wingdi.h:1255
#define DM_PANNINGHEIGHT
Definition: wingdi.h:1278
#define DM_BITSPERPEL
Definition: wingdi.h:1268
#define DM_DISPLAYORIENTATION
Definition: wingdi.h:1257
#define DM_PELSHEIGHT
Definition: wingdi.h:1270
#define DM_PANNINGWIDTH
Definition: wingdi.h:1277
#define DM_DISPLAYFLAGS
Definition: wingdi.h:1271

Referenced by UserEnumRegistryDisplaySettings().

◆ RegWriteDisplaySettings()

VOID RegWriteDisplaySettings ( HKEY  hkey,
PDEVMODEW  pdm 
)

Definition at line 18 of file display.c.

19{
20 RegWriteDWORD(hkey, L"DefaultSettings.BitsPerPel", pdm->dmBitsPerPel);
21 RegWriteDWORD(hkey, L"DefaultSettings.XResolution", pdm->dmPelsWidth);
22 RegWriteDWORD(hkey, L"DefaultSettings.YResolution", pdm->dmPelsHeight);
23 RegWriteDWORD(hkey, L"DefaultSettings.Flags", pdm->dmDisplayFlags);
24 RegWriteDWORD(hkey, L"DefaultSettings.VRefresh", pdm->dmDisplayFrequency);
25 RegWriteDWORD(hkey, L"DefaultSettings.XPanning", pdm->dmPanningWidth);
26 RegWriteDWORD(hkey, L"DefaultSettings.YPanning", pdm->dmPanningHeight);
27 RegWriteDWORD(hkey, L"DefaultSettings.Orientation", pdm->dmDisplayOrientation);
28 RegWriteDWORD(hkey, L"DefaultSettings.FixedOutput", pdm->dmDisplayFixedOutput);
29 RegWriteDWORD(hkey, L"Attach.RelativeX", pdm->dmPosition.x);
30 RegWriteDWORD(hkey, L"Attach.RelativeY", pdm->dmPosition.y);
31// RegWriteDWORD(hkey, L"Attach.ToDesktop, pdm->dmBitsPerPel", pdm->);
32}
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
DWORD dmBitsPerPel
Definition: wingdi.h:1647
POINTL dmPosition
Definition: wingdi.h:1635
DWORD dmDisplayFixedOutput
Definition: wingdi.h:1637
DWORD dmDisplayOrientation
Definition: wingdi.h:1636
DWORD dmPelsWidth
Definition: wingdi.h:1648
DWORD dmDisplayFlags
Definition: wingdi.h:1651
DWORD dmPelsHeight
Definition: wingdi.h:1649
DWORD dmDisplayFrequency
Definition: wingdi.h:1654
VOID NTAPI RegWriteDWORD(HKEY hkey, PCWSTR pwszValue, DWORD dwData)
Definition: registry.c:139

Referenced by UserChangeDisplaySettings().

◆ UserChangeDisplaySettings()

LONG APIENTRY UserChangeDisplaySettings ( PUNICODE_STRING  pustrDevice,
LPDEVMODEW  pdm,
DWORD  flags,
LPVOID  lParam 
)

Definition at line 700 of file display.c.

705{
706 DEVMODEW dm;
708 HKEY hkey;
710 PPDEVOBJ ppdev;
711 WORD OrigBC;
712 //PDESKTOP pdesk;
713 PDEVMODEW newDevMode = NULL;
714
715 /* If no DEVMODE is given, use registry settings */
716 if (!pdm)
717 {
718 /* Get the registry settings */
719 Status = UserEnumRegistryDisplaySettings(pustrDevice, &dm);
720 if (!NT_SUCCESS(Status))
721 {
722 ERR("Could not load registry settings\n");
724 }
725 }
726 else if (pdm->dmSize < FIELD_OFFSET(DEVMODEW, dmFields))
727 {
728 return DISP_CHANGE_BADMODE; /* This is what WinXP SP3 returns */
729 }
730 else
731 {
732 dm = *pdm;
733 }
734
735 /* Save original bit count */
736 OrigBC = gpsi->BitCount;
737
738 /* Check params */
740 {
741 ERR("Devmode doesn't specify the resolution.\n");
742 return DISP_CHANGE_BADMODE;
743 }
744
745 /* Get the PDEV */
746 ppdev = EngpGetPDEV(pustrDevice);
747 if (!ppdev)
748 {
749 ERR("Failed to get PDEV\n");
751 }
752
753 /* Fixup values */
754 if (dm.dmBitsPerPel == 0 || !(dm.dmFields & DM_BITSPERPEL))
755 {
756 dm.dmBitsPerPel = ppdev->pdmwDev->dmBitsPerPel;
758 }
759
760 if ((dm.dmFields & DM_DISPLAYFREQUENCY) && (dm.dmDisplayFrequency == 0))
762
763 /* Look for the requested DEVMODE */
764 if (!LDEVOBJ_bProbeAndCaptureDevmode(ppdev->pGraphicsDevice, &dm, &newDevMode, FALSE))
765 {
766 ERR("Could not find a matching DEVMODE\n");
767 lResult = DISP_CHANGE_BADMODE;
768 goto leave;
769 }
770 else if (flags & CDS_TEST)
771 {
772 /* It's possible, go ahead! */
773 lResult = DISP_CHANGE_SUCCESSFUL;
774 goto leave;
775 }
776
777 /* Shall we update the registry? */
779 {
780 /* Open the local or global settings key */
781 Status = UserOpenDisplaySettingsKey(&hkey, pustrDevice, flags & CDS_GLOBAL);
782 if (NT_SUCCESS(Status))
783 {
784 /* Store the settings */
785 RegWriteDisplaySettings(hkey, newDevMode);
786
787 /* Close the registry key */
788 ZwClose(hkey);
789 }
790 else
791 {
792 ERR("Could not open registry key\n");
793 lResult = DISP_CHANGE_NOTUPDATED;
794 }
795 }
796
797 /* Check if DEVMODE matches the current mode */
798 if (newDevMode->dmSize == ppdev->pdmwDev->dmSize &&
799 RtlCompareMemory(newDevMode, ppdev->pdmwDev, newDevMode->dmSize) == newDevMode->dmSize &&
800 !(flags & CDS_RESET))
801 {
802 ERR("DEVMODE matches, nothing to do\n");
803 goto leave;
804 }
805
806 /* Shall we apply the settings? */
807 if (!(flags & CDS_NORESET))
808 {
809 ULONG_PTR ulResult;
810 PVOID pvOldCursor;
811 TEXTMETRICW tmw;
812
813 /* Remove mouse pointer */
814 pvOldCursor = UserSetCursor(NULL, TRUE);
815
816 /* Do the mode switch */
817 ulResult = PDEVOBJ_bSwitchMode(ppdev, newDevMode);
818
819 /* Restore mouse pointer, no hooks called */
820 pvOldCursor = UserSetCursor(pvOldCursor, TRUE);
821 ASSERT(pvOldCursor == NULL);
822
823 /* Check for success or failure */
824 if (!ulResult)
825 {
826 /* Setting mode failed */
827 ERR("Failed to set mode\n");
828
829 /* Set the correct return value */
830 if ((flags & CDS_UPDATEREGISTRY) && (lResult != DISP_CHANGE_NOTUPDATED))
831 lResult = DISP_CHANGE_RESTART;
832 else
833 lResult = DISP_CHANGE_FAILED;
834 }
835 else
836 {
837 /* Setting mode succeeded */
838 lResult = DISP_CHANGE_SUCCESSFUL;
840 ppdev->pdmwDev = newDevMode;
841
843
844 /* Update the system metrics */
845 InitMetrics();
846
847 /* Set new size of the monitor */
848 UserUpdateMonitorSize((HDEV)ppdev);
849
850 /* Update the SERVERINFO */
851 gpsi->dmLogPixels = ppdev->gdiinfo.ulLogPixelsY;
852 gpsi->Planes = ppdev->gdiinfo.cPlanes;
853 gpsi->BitsPixel = ppdev->gdiinfo.cBitsPixel;
854 gpsi->BitCount = gpsi->Planes * gpsi->BitsPixel;
855 gpsi->aiSysMet[SM_CXSCREEN] = ppdev->gdiinfo.ulHorzRes;
856 gpsi->aiSysMet[SM_CYSCREEN] = ppdev->gdiinfo.ulVertRes;
857 if (ppdev->gdiinfo.flRaster & RC_PALETTE)
858 {
859 gpsi->PUSIFlags |= PUSIF_PALETTEDISPLAY;
860 }
861 else
862 {
863 gpsi->PUSIFlags &= ~PUSIF_PALETTEDISPLAY;
864 }
865 // Font is realized and this dc was previously set to internal DC_ATTR.
866 gpsi->cxSysFontChar = IntGetCharDimensions(hSystemBM, &tmw, (DWORD*)&gpsi->cySysFontChar);
867 gpsi->tmSysFont = tmw;
868 }
869
870 /*
871 * Refresh the display on success and even on failure,
872 * since the display may have been messed up.
873 */
874
875 /* Remove all cursor clipping */
877
878 //pdesk = IntGetActiveDesktop();
879 //IntHideDesktop(pdesk);
880
881 /* Send WM_DISPLAYCHANGE to all toplevel windows */
883 WM_DISPLAYCHANGE,
884 gpsi->BitCount,
885 MAKELONG(gpsi->aiSysMet[SM_CXSCREEN], gpsi->aiSysMet[SM_CYSCREEN]),
887 100,
888 &ulResult );
889
890 ERR("BitCount New %d Orig %d ChkNew %d\n",gpsi->BitCount,OrigBC,ppdev->gdiinfo.cBitsPixel);
891
892 /* Not full screen and different bit count, send messages */
893 if (!(flags & CDS_FULLSCREEN) &&
894 gpsi->BitCount != OrigBC)
895 {
896 ERR("Detect settings changed.\n");
899 }
900
901 //co_IntShowDesktop(pdesk, ppdev->gdiinfo.ulHorzRes, ppdev->gdiinfo.ulVertRes);
902
904 }
905
906leave:
907 if (newDevMode && newDevMode != ppdev->pdmwDev)
909
910 /* Release the PDEV */
911 PDEVOBJ_vRelease(ppdev);
912
913 return lResult;
914}
#define leave
Definition: btrfs_drv.h:138
#define TRUE
Definition: types.h:120
PSERVERINFO gpsi
Definition: imm.c:18
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
unsigned short WORD
Definition: ntddk_ex.h:93
GLbitfield flags
Definition: glext.h:7161
#define PUSIF_PALETTEDISPLAY
Definition: ntuser.h:993
HDC hSystemBM
Definition: stockobj.c:52
BOOL LDEVOBJ_bProbeAndCaptureDevmode(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW RequestedMode, _Out_ PDEVMODEW *pSelectedMode, _In_ BOOL bSearchClosestMode)
Definition: ldevobj.c:737
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
PCURICON_OBJECT FASTCALL UserSetCursor(PCURICON_OBJECT NewCursor, BOOL ForceChange)
Definition: msgqueue.c:93
PPDEVOBJ NTAPI EngpGetPDEV(_In_opt_ PUNICODE_STRING pustrDeviceName)
Definition: pdevobj.c:815
BOOL NTAPI PDEVOBJ_bSwitchMode(PPDEVOBJ ppdev, PDEVMODEW pdm)
Definition: pdevobj.c:712
VOID NTAPI PDEVOBJ_vRelease(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:105
ULONG ulLogPixelsY
Definition: winddi.h:889
ULONG cBitsPixel
Definition: winddi.h:884
ULONG ulVertRes
Definition: winddi.h:883
ULONG ulHorzRes
Definition: winddi.h:882
ULONG flRaster
Definition: winddi.h:887
ULONG cPlanes
Definition: winddi.h:885
GDIINFO gdiinfo
Definition: pdevobj.h:123
PDEVMODEW pdmwDev
Definition: pdevobj.h:129
PGRAPHICS_DEVICE pGraphicsDevice
Definition: pdevobj.h:127
DWORD dmFields
Definition: wingdi.h:1622
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MAKELONG(a, b)
Definition: typedefs.h:249
DWORD FASTCALL IntGetCharDimensions(HDC hdc, PTEXTMETRICW ptm, PDWORD height)
Definition: font.c:329
BOOL APIENTRY UserClipCursor(RECTL *prcl)
Definition: cursoricon.c:700
VOID APIENTRY UserRedrawDesktop(VOID)
Definition: desktop.c:1616
VOID UserUpdateFullscreen(DWORD flags)
Definition: display.c:689
VOID RegWriteDisplaySettings(HKEY hkey, PDEVMODEW pdm)
Definition: display.c:18
NTSTATUS NTAPI UserOpenDisplaySettingsKey(OUT PHKEY phkey, IN PUNICODE_STRING pustrDevice, IN BOOL bGlobal)
Definition: display.c:524
BOOL FASTCALL UserSendNotifyMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2090
LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult)
Definition: message.c:1707
BOOL NTAPI InitMetrics(VOID)
Definition: metric.c:45
NTSTATUS NTAPI UserUpdateMonitorSize(IN HDEV hDev)
Definition: monitor.c:225
#define GDITAG_DEVMODE
Definition: tags.h:73
#define RC_PALETTE
Definition: wingdi.h:790
#define CDS_TEST
Definition: winuser.h:182
#define DISP_CHANGE_NOTUPDATED
Definition: winuser.h:196
#define SM_CYSCREEN
Definition: winuser.h:963
#define DISP_CHANGE_BADMODE
Definition: winuser.h:195
#define HWND_BROADCAST
Definition: winuser.h:1207
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
#define CDS_FULLSCREEN
Definition: winuser.h:183
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1629
#define DISP_CHANGE_FAILED
Definition: winuser.h:194
#define WM_SETTINGCHANGE
Definition: winuser.h:1632
#define SM_CXSCREEN
Definition: winuser.h:962
#define DISP_CHANGE_RESTART
Definition: winuser.h:191
#define SMTO_NORMAL
Definition: winuser.h:1228

Referenced by NtUserChangeDisplaySettings(), and UserDisplayNotifyShutdown().

◆ UserDisplayNotifyShutdown()

VOID UserDisplayNotifyShutdown ( PPROCESSINFO  ppiCurrent)

Definition at line 917 of file display.c.

919{
920 if (ppiCurrent == gpFullscreen)
921 {
923 if (gpFullscreen)
924 ERR("Failed to restore display mode!\n");
925 }
926}
static PPROCESSINFO gpFullscreen
Definition: display.c:13

Referenced by ExitThreadCallback().

◆ UserEnumCurrentDisplaySettings()

NTSTATUS NTAPI UserEnumCurrentDisplaySettings ( PUNICODE_STRING  pustrDevice,
PDEVMODEW ppdm 
)

Definition at line 441 of file display.c.

444{
445 PPDEVOBJ ppdev;
446
447 /* Get the PDEV for the device */
448 ppdev = EngpGetPDEV(pustrDevice);
449 if (!ppdev)
450 {
451 /* No device found */
452 ERR("No PDEV found!\n");
454 }
455
456 *ppdm = ppdev->pdmwDev;
457 PDEVOBJ_vRelease(ppdev);
458
459 return STATUS_SUCCESS;
460}

Referenced by NtUserEnumDisplaySettings().

◆ UserEnumDisplayDevices()

NTSTATUS NTAPI UserEnumDisplayDevices ( PUNICODE_STRING  pustrDevice,
DWORD  iDevNum,
PDISPLAY_DEVICEW  pdispdev,
DWORD  dwFlags 
)

Definition at line 217 of file display.c.

222{
223 PGRAPHICS_DEVICE pGraphicsDevice;
224 PDEVICE_OBJECT pdo;
225 PWCHAR pHardwareId;
226 ULONG cbSize, dwLength;
227 HKEY hkey;
229
230 if (!pustrDevice)
231 {
232 /* Check if some devices have been added since last time */
234 }
235
236 /* Ask gdi for the GRAPHICS_DEVICE */
237 pGraphicsDevice = EngpFindGraphicsDevice(pustrDevice, iDevNum);
238 if (!pGraphicsDevice)
239 {
240 /* No device found */
241 if (iDevNum == 0)
242 ERR("No GRAPHICS_DEVICE found for '%wZ', iDevNum %lu\n", pustrDevice, iDevNum);
243 else
244 TRACE("No GRAPHICS_DEVICE found for '%wZ', iDevNum %lu\n", pustrDevice, iDevNum);
245 return STATUS_UNSUCCESSFUL;
246 }
247
248 /* Open the device map registry key */
249 Status = RegOpenKey(KEY_VIDEO, &hkey);
250 if (!NT_SUCCESS(Status))
251 {
252 /* No device found */
253 ERR("Could not open reg key\n");
254 return STATUS_UNSUCCESSFUL;
255 }
256
257 /* Query the registry path */
258 cbSize = sizeof(pdispdev->DeviceKey);
259 RegQueryValue(hkey,
260 pGraphicsDevice->szNtDeviceName,
261 REG_SZ,
262 pdispdev->DeviceKey,
263 &cbSize);
264
265 /* Close registry key */
266 ZwClose(hkey);
267
268 /* Copy device name, device string and StateFlags */
269 RtlStringCbCopyW(pdispdev->DeviceName, sizeof(pdispdev->DeviceName), pGraphicsDevice->szWinDeviceName);
270 RtlStringCbCopyW(pdispdev->DeviceString, sizeof(pdispdev->DeviceString), pGraphicsDevice->pwszDescription);
271 pdispdev->StateFlags = pGraphicsDevice->StateFlags;
272 pdispdev->DeviceID[0] = UNICODE_NULL;
273
274 /* Fill in DeviceID */
275 if (!pustrDevice)
276 pdo = pGraphicsDevice->PhysDeviceHandle;
277 else
278#if 0
279 pdo = pGraphicsDevice->pvMonDev[iDevNum].pdo;
280#else
281 /* FIXME: pvMonDev not initialized, see EngpRegisterGraphicsDevice */
282 pdo = NULL;
283#endif
284
285 if (pdo != NULL)
286 {
289 0,
290 NULL,
291 &dwLength);
292
294 {
295 pHardwareId = ExAllocatePoolWithTag(PagedPool,
296 dwLength,
298 if (!pHardwareId)
299 {
302 }
303
306 dwLength,
307 pHardwareId,
308 &dwLength);
309
310 if (!NT_SUCCESS(Status))
311 {
312 ERR("IoGetDeviceProperty() failed with status 0x%08lx\n", Status);
313 }
314 else
315 {
316 /* For video adapters it should be the first Hardware ID
317 * which usually is the longest one and unique enough */
318 RtlStringCbCopyW(pdispdev->DeviceID, sizeof(pdispdev->DeviceID), pHardwareId);
319
320 if (pustrDevice)
321 {
322 /* For monitors it should be the first Hardware ID,
323 * which we already have obtained above,
324 * concatenated with the unique driver registry key */
325
326 RtlStringCbCatW(pdispdev->DeviceID, sizeof(pdispdev->DeviceID), L"\\");
327
328 /* FIXME: DevicePropertyDriverKeyName string should be appended */
329 pHardwareId[0] = UNICODE_NULL;
330 RtlStringCbCatW(pdispdev->DeviceID, sizeof(pdispdev->DeviceID), pHardwareId);
331 }
332
333 TRACE("Hardware ID: %ls\n", pdispdev->DeviceID);
334 }
335
337 }
338 else
339 {
340 ERR("IoGetDeviceProperty() failed with status 0x%08lx\n", Status);
341 }
342 }
343
344 return STATUS_SUCCESS;
345}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static DWORD DWORD * dwLength
Definition: fusion.c:86
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define UNICODE_NULL
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
NTSTRSAFEAPI RtlStringCbCatW(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:636
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1382
WCHAR DeviceName[32]
Definition: wingdi.h:2818
DWORD StateFlags
Definition: wingdi.h:2820
WCHAR DeviceString[128]
Definition: wingdi.h:2819
WCHAR DeviceKey[128]
Definition: wingdi.h:2822
WCHAR DeviceID[128]
Definition: wingdi.h:2821
WCHAR szWinDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:60
WCHAR szNtDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:59
LPWSTR pwszDescription
Definition: pdevobj.h:72
PVIDEO_MONITOR_DEVICE pvMonDev
Definition: pdevobj.h:74
PDEVICE_OBJECT PhysDeviceHandle
Definition: pdevobj.h:64
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice(_In_opt_ PUNICODE_STRING pustrDevice, _In_ ULONG iDevNum)
Definition: device.c:641
static const PWCHAR KEY_VIDEO
Definition: display.c:15
#define USERTAG_DISPLAYINFO
Definition: tags.h:225
@ DevicePropertyHardwareID
Definition: iotypes.h:1196

Referenced by NtUserEnumDisplayDevices(), and UserOpenDisplaySettingsKey().

◆ UserEnumDisplaySettings()

NTSTATUS NTAPI UserEnumDisplaySettings ( PUNICODE_STRING  pustrDevice,
DWORD  iModeNum,
LPDEVMODEW ppdm,
DWORD  dwFlags 
)

Definition at line 464 of file display.c.

469{
470 PGRAPHICS_DEVICE pGraphicsDevice;
471 PDEVMODEENTRY pdmentry;
472 ULONG i, iFoundMode;
473 PPDEVOBJ ppdev;
474
475 TRACE("Enter UserEnumDisplaySettings('%wZ', %lu)\n",
476 pustrDevice, iModeNum);
477
478 /* Ask GDI for the GRAPHICS_DEVICE */
479 pGraphicsDevice = EngpFindGraphicsDevice(pustrDevice, 0);
480 ppdev = EngpGetPDEV(pustrDevice);
481
482 if (!pGraphicsDevice || !ppdev)
483 {
484 /* No device found */
485 ERR("No device found!\n");
487 }
488
489 /* let's politely ask the driver for an updated mode list,
490 just in case there's something new in there (vbox) */
491
493 PDEVOBJ_vRelease(ppdev);
494
495 iFoundMode = 0;
496 for (i = 0; i < pGraphicsDevice->cDevModes; i++)
497 {
498 pdmentry = &pGraphicsDevice->pDevModeList[i];
499
500 /* FIXME: Consider EDS_RAWMODE */
501#if 0
502 if ((!(dwFlags & EDS_RAWMODE) && (pdmentry->dwFlags & 1)) ||!
503 (dwFlags & EDS_RAWMODE))
504#endif
505 {
506 /* Is this the one we want? */
507 if (iFoundMode == iModeNum)
508 {
509 *ppdm = pdmentry->pdm;
510 return STATUS_SUCCESS;
511 }
512
513 /* Increment number of found modes */
514 iFoundMode++;
515 }
516 }
517
518 /* Nothing was found */
520}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
PDEVMODEW pdm
Definition: pdevobj.h:53
DWORD dwFlags
Definition: pdevobj.h:52
PDEVMODEENTRY pDevModeList
Definition: pdevobj.h:70
ULONG cDevModes
Definition: pdevobj.h:69
VOID NTAPI PDEVOBJ_vRefreshModeList(PPDEVOBJ ppdev)
Definition: pdevobj.c:436

Referenced by NtUserEnumDisplaySettings().

◆ UserEnumRegistryDisplaySettings()

NTSTATUS NTAPI UserEnumRegistryDisplaySettings ( IN PUNICODE_STRING  pustrDevice,
OUT LPDEVMODEW  pdm 
)

Definition at line 555 of file display.c.

558{
559 HKEY hkey;
560 NTSTATUS Status = UserOpenDisplaySettingsKey(&hkey, pustrDevice, 0);
561 if(NT_SUCCESS(Status))
562 {
563 RegReadDisplaySettings(hkey, pdm);
564 ZwClose(hkey);
565 return STATUS_SUCCESS;
566 }
567 return Status;
568}
VOID RegReadDisplaySettings(HKEY hkey, PDEVMODEW pdm)
Definition: display.c:35

Referenced by NtUserEnumDisplaySettings(), and UserChangeDisplaySettings().

◆ UserOpenDisplaySettingsKey()

NTSTATUS NTAPI UserOpenDisplaySettingsKey ( OUT PHKEY  phkey,
IN PUNICODE_STRING  pustrDevice,
IN BOOL  bGlobal 
)

Definition at line 524 of file display.c.

528{
529 HKEY hkey;
530 DISPLAY_DEVICEW dispdev;
532
533 /* Get device info */
534 Status = UserEnumDisplayDevices(pustrDevice, 0, &dispdev, 0);
535 if (!NT_SUCCESS(Status))
536 return Status;
537
538 if (bGlobal)
539 {
540 // FIXME: Need to fix the registry key somehow
541 }
542
543 /* Open the registry key */
544 Status = RegOpenKey(dispdev.DeviceKey, &hkey);
545 if (!NT_SUCCESS(Status))
546 return Status;
547
548 *phkey = hkey;
549
550 return Status;
551}

Referenced by UserChangeDisplaySettings(), and UserEnumRegistryDisplaySettings().

◆ UserRefreshDisplay()

VOID UserRefreshDisplay ( IN PPDEVOBJ  ppdev)

Definition at line 177 of file display.c.

178{
179 ULONG_PTR ulResult;
180 // PVOID pvOldCursor;
181
182 // TODO: Re-enable the cursor reset code once this function becomes called
183 // from within a Win32 thread... Indeed UserSetCursor() requires this, but
184 // at the moment this function is directly called from a separate thread
185 // from within videoprt, instead of by a separate win32k system thread.
186
187 if (!ppdev)
188 return;
189
190 PDEVOBJ_vReference(ppdev);
191
192 /* Remove mouse pointer */
193 // pvOldCursor = UserSetCursor(NULL, TRUE);
194
195 /* Do the mode switch -- Use the actual same current mode */
196 ulResult = PDEVOBJ_bSwitchMode(ppdev, ppdev->pdmwDev);
197 ASSERT(ulResult);
198
199 /* Restore mouse pointer, no hooks called */
200 // pvOldCursor = UserSetCursor(pvOldCursor, TRUE);
201 // ASSERT(pvOldCursor == NULL);
202
203 /* Update the system metrics */
204 InitMetrics();
205
206 /* Set new size of the monitor */
207 // UserUpdateMonitorSize((HDEV)ppdev);
208
209 //co_IntShowDesktop(pdesk, ppdev->gdiinfo.ulHorzRes, ppdev->gdiinfo.ulVertRes);
211
212 PDEVOBJ_vRelease(ppdev);
213}
FORCEINLINE VOID PDEVOBJ_vReference(_In_ PPDEVOBJ ppdev)
Definition: pdevobj.h:160

Referenced by VideoPortCallout().

◆ UserUpdateFullscreen()

VOID UserUpdateFullscreen ( DWORD  flags)

Definition at line 689 of file display.c.

691{
692 if (flags & CDS_FULLSCREEN)
694 else
696}
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
PPROCESSINFO ppi
Definition: win32.h:88

Referenced by UserChangeDisplaySettings().

Variable Documentation

◆ gbBaseVideo

BOOL gbBaseVideo = FALSE

Definition at line 12 of file display.c.

Referenced by EngpUpdateGraphicsDeviceList(), and InitVideo().

◆ gpFullscreen

PPROCESSINFO gpFullscreen = NULL
static

Definition at line 13 of file display.c.

Referenced by UserDisplayNotifyShutdown(), and UserUpdateFullscreen().

◆ KEY_VIDEO

const PWCHAR KEY_VIDEO = L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP\\VIDEO"
static

Definition at line 15 of file display.c.

Referenced by EngpGetRegistryHandleFromDeviceMap(), and UserEnumDisplayDevices().