ReactOS  0.4.13-dev-563-g0561610
display.c File Reference
#include <user32.h>
Include dependency graph for display.c:

Go to the source code of this file.

Macros

#define SIZEOF_DEVMODEA_300   124
 
#define SIZEOF_DEVMODEA_400   148
 
#define SIZEOF_DEVMODEA_500   156
 
#define SIZEOF_DEVMODEW_300   188
 
#define SIZEOF_DEVMODEW_400   212
 
#define SIZEOF_DEVMODEW_500   220
 
#define COPYS(f, len)   WideCharToMultiByte(CP_THREAD_ACP, 0, lpExtendedDevMode->f, len, (LPSTR)lpDevMode->f, len, NULL, NULL)
 
#define COPYN(f)   lpDevMode->f = lpExtendedDevMode->f
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (user32)
 
BOOL WINAPI EnumDisplayDevicesA (LPCSTR lpDevice, DWORD iDevNum, PDISPLAY_DEVICEA lpDisplayDevice, DWORD dwFlags)
 
BOOL WINAPI EnumDisplayDevicesW (LPCWSTR lpDevice, DWORD iDevNum, PDISPLAY_DEVICEW lpDisplayDevice, DWORD dwFlags)
 
BOOL WINAPI EnumDisplayMonitors (HDC hdc, LPCRECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData)
 
BOOL WINAPI EnumDisplaySettingsExA (LPCSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEA lpDevMode, DWORD dwFlags)
 
BOOL WINAPI EnumDisplaySettingsA (LPCSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEA lpDevMode)
 
BOOL WINAPI EnumDisplaySettingsExW (LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode, DWORD dwFlags)
 
BOOL WINAPI EnumDisplaySettingsW (LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode)
 
BOOL WINAPI GetMonitorInfoA (HMONITOR hMonitor, LPMONITORINFO lpmi)
 
BOOL WINAPI GetMonitorInfoW (HMONITOR hMonitor, LPMONITORINFO lpmi)
 
HMONITOR WINAPI MonitorFromPoint (IN POINT ptPoint, IN DWORD dwFlags)
 
HMONITOR WINAPI MonitorFromRect (IN LPCRECT lpcRect, IN DWORD dwFlags)
 
HMONITOR WINAPI MonitorFromWindow (IN HWND hWnd, IN DWORD dwFlags)
 
LONG WINAPI ChangeDisplaySettingsExA (LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
 
LONG WINAPI ChangeDisplaySettingsA (LPDEVMODEA lpDevMode, DWORD dwflags)
 
LONG WINAPI ChangeDisplaySettingsExW (LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
 
LONG WINAPI ChangeDisplaySettingsW (LPDEVMODEW lpDevMode, DWORD dwflags)
 

Macro Definition Documentation

◆ COPYN

#define COPYN (   f)    lpDevMode->f = lpExtendedDevMode->f

◆ COPYS

#define COPYS (   f,
  len 
)    WideCharToMultiByte(CP_THREAD_ACP, 0, lpExtendedDevMode->f, len, (LPSTR)lpDevMode->f, len, NULL, NULL)

◆ SIZEOF_DEVMODEA_300

#define SIZEOF_DEVMODEA_300   124

Definition at line 12 of file display.c.

◆ SIZEOF_DEVMODEA_400

#define SIZEOF_DEVMODEA_400   148

Definition at line 13 of file display.c.

◆ SIZEOF_DEVMODEA_500

#define SIZEOF_DEVMODEA_500   156

Definition at line 14 of file display.c.

◆ SIZEOF_DEVMODEW_300

#define SIZEOF_DEVMODEW_300   188

Definition at line 15 of file display.c.

◆ SIZEOF_DEVMODEW_400

#define SIZEOF_DEVMODEW_400   212

Definition at line 16 of file display.c.

◆ SIZEOF_DEVMODEW_500

#define SIZEOF_DEVMODEW_500   220

Definition at line 17 of file display.c.

Function Documentation

◆ ChangeDisplaySettingsA()

LONG WINAPI ChangeDisplaySettingsA ( LPDEVMODEA  lpDevMode,
DWORD  dwflags 
)

Definition at line 570 of file display.c.

573 {
574  if(lpDevMode)
577 }
LONG WINAPI ChangeDisplaySettingsExA(LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
Definition: display.c:521
WORD dmDriverExtra
Definition: wingdi.h:1547
smooth NULL
Definition: ftsmooth.c:416
static _In_ DWORD _Inout_ PDEVMODEA lpDevMode
Definition: dispmode.c:77
static _In_ DWORD dwflags
Definition: dispmode.c:64

Referenced by Notify(), and test_ChangeDisplaySettingsEx().

◆ ChangeDisplaySettingsExA()

LONG WINAPI ChangeDisplaySettingsExA ( LPCSTR  lpszDeviceName,
LPDEVMODEA  lpDevMode,
HWND  hwnd,
DWORD  dwflags,
LPVOID  lParam 
)

Definition at line 521 of file display.c.

527 {
528  LONG rc;
530  PUNICODE_STRING pDeviceName = &DeviceName;
531 
532  if (lpszDeviceName != NULL)
533  {
534  if (!RtlCreateUnicodeStringFromAsciiz(pDeviceName, (PCSZ)lpszDeviceName))
535  {
537  return DISP_CHANGE_BADPARAM; /* FIXME what to return? */
538  }
539  }
540  else
541  pDeviceName = NULL;
542 
543  if (lpDevMode != NULL)
544  {
545  LPDEVMODEW pDevModeW;
546  pDevModeW = GdiConvertToDevmodeW(lpDevMode);
547  if(pDevModeW)
548  {
549  rc = NtUserChangeDisplaySettings(pDeviceName, pDevModeW, dwflags, lParam);
550  RtlFreeHeap(GetProcessHeap(), 0, pDevModeW);
551  }
552  else
554  }
555  else
556  rc = NtUserChangeDisplaySettings(pDeviceName, NULL, dwflags, lParam);
557 
558  if (lpszDeviceName != NULL)
560 
561  return rc;
562 }
CONST char * PCSZ
Definition: umtypes.h:125
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
WCHAR DeviceName[]
Definition: adapter.cpp:21
DEVMODEW *WINAPI GdiConvertToDevmodeW(const DEVMODEA *)
Definition: misc.c:968
long LONG
Definition: pedump.c:60
#define DISP_CHANGE_BADPARAM
Definition: winuser.h:193
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
static _In_ DWORD _Inout_ PDEVMODEA lpDevMode
Definition: dispmode.c:77
#define GetProcessHeap()
Definition: compat.h:395
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
static _In_ DWORD dwflags
Definition: dispmode.c:64
LONG APIENTRY NtUserChangeDisplaySettings(PUNICODE_STRING pustrDevice, LPDEVMODEW lpDevMode, DWORD dwflags, LPVOID lParam)
Definition: display.c:905
LPARAM lParam
Definition: combotst.c:139
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by ChangeDisplaySettingsA(), and init_function_pointers().

◆ ChangeDisplaySettingsExW()

LONG WINAPI ChangeDisplaySettingsExW ( LPCWSTR  lpszDeviceName,
LPDEVMODEW  lpDevMode,
HWND  hwnd,
DWORD  dwflags,
LPVOID  lParam 
)

Definition at line 585 of file display.c.

591 {
592  LONG rc;
594  PUNICODE_STRING pDeviceName = &DeviceName;
595 
596  if (lpszDeviceName != NULL)
597  RtlInitUnicodeString(pDeviceName, lpszDeviceName);
598  else
599  pDeviceName = NULL;
600 
602 
603  return rc;
604 }
WCHAR DeviceName[]
Definition: adapter.cpp:21
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
static _In_ DWORD _Inout_ PDEVMODEA lpDevMode
Definition: dispmode.c:77
static _In_ DWORD dwflags
Definition: dispmode.c:64
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
LONG APIENTRY NtUserChangeDisplaySettings(PUNICODE_STRING pustrDevice, LPDEVMODEW lpDevMode, DWORD dwflags, LPVOID lParam)
Definition: display.c:905
LPARAM lParam
Definition: combotst.c:139

Referenced by ChangeDisplaySettingsW(), init_function_pointers(), START_TEST(), and wined3d_set_adapter_display_mode().

◆ ChangeDisplaySettingsW()

LONG WINAPI ChangeDisplaySettingsW ( LPDEVMODEW  lpDevMode,
DWORD  dwflags 
)

Definition at line 612 of file display.c.

615 {
616  if(lpDevMode)
619 }
WORD dmDriverExtra
Definition: wingdi.h:1547
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
Definition: display.c:585
smooth NULL
Definition: ftsmooth.c:416
static _In_ DWORD _Inout_ PDEVMODEA lpDevMode
Definition: dispmode.c:77
static _In_ DWORD dwflags
Definition: dispmode.c:64

Referenced by EnterFullScreen(), LeaveFullScreen(), ProcessUnattendSection(), and test_ChangeDisplaySettingsEx().

◆ EnumDisplayDevicesA()

BOOL WINAPI EnumDisplayDevicesA ( LPCSTR  lpDevice,
DWORD  iDevNum,
PDISPLAY_DEVICEA  lpDisplayDevice,
DWORD  dwFlags 
)

Definition at line 23 of file display.c.

28 {
29  BOOL rc;
31  DISPLAY_DEVICEW DisplayDeviceW;
32 
34  {
36  return FALSE;
37  }
38 
39  RtlZeroMemory(&DisplayDeviceW, sizeof(DISPLAY_DEVICEW));
40  DisplayDeviceW.cb = sizeof(DISPLAY_DEVICEW);
42  iDevNum,
43  &DisplayDeviceW,
44  dwFlags);
45  if (rc)
46  {
47  /* Copy result from DisplayDeviceW to lpDisplayDevice. Buffers have the same size so result is always NULL terminated. */
48  lpDisplayDevice->StateFlags = DisplayDeviceW.StateFlags;
49  WideCharToMultiByte(CP_ACP, 0, DisplayDeviceW.DeviceName, -1,
50  lpDisplayDevice->DeviceName,
51  sizeof(lpDisplayDevice->DeviceName) / sizeof(lpDisplayDevice->DeviceName[0]),
52  NULL, NULL);
53  WideCharToMultiByte(CP_ACP, 0, DisplayDeviceW.DeviceString, -1,
54  lpDisplayDevice->DeviceString,
55  sizeof(lpDisplayDevice->DeviceString) / sizeof(lpDisplayDevice->DeviceString[0]),
56  NULL, NULL);
57  WideCharToMultiByte(CP_ACP, 0, DisplayDeviceW.DeviceID, -1,
58  lpDisplayDevice->DeviceID,
59  sizeof(lpDisplayDevice->DeviceID) / sizeof(lpDisplayDevice->DeviceID[0]),
60  NULL, NULL);
61  WideCharToMultiByte(CP_ACP, 0, DisplayDeviceW.DeviceKey, -1,
62  lpDisplayDevice->DeviceKey,
63  sizeof(lpDisplayDevice->DeviceKey) / sizeof(lpDisplayDevice->DeviceKey[0]),
64  NULL, NULL);
65  }
66 
68 
69  return rc;
70 }
CONST char * PCSZ
Definition: umtypes.h:125
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
#define WideCharToMultiByte
Definition: compat.h:101
CHAR DeviceString[128]
Definition: wingdi.h:2789
#define CP_ACP
Definition: compat.h:99
WCHAR DeviceString[128]
Definition: wingdi.h:2797
CHAR DeviceName[32]
Definition: wingdi.h:2788
WCHAR DeviceName[32]
Definition: wingdi.h:2796
BOOL NTAPI NtUserEnumDisplayDevices(PUNICODE_STRING pustrDevice, DWORD iDevNum, PDISPLAY_DEVICEW pDisplayDevice, DWORD dwFlags)
Definition: display.c:343
unsigned int BOOL
Definition: ntddk_ex.h:94
WCHAR DeviceID[128]
Definition: wingdi.h:2799
CHAR DeviceKey[128]
Definition: wingdi.h:2792
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
DWORD StateFlags
Definition: wingdi.h:2798
struct _DISPLAY_DEVICEW DISPLAY_DEVICEW
WCHAR DeviceKey[128]
Definition: wingdi.h:2800
DWORD StateFlags
Definition: wingdi.h:2790
CHAR DeviceID[128]
Definition: wingdi.h:2791
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by GetAdapterInfo(), GetDisplayDeviceInfo(), init_function_pointers(), Main_DirectDraw_GetDeviceIdentifier7(), and testSetupDiGetClassDevsA().

◆ EnumDisplayDevicesW()

BOOL WINAPI EnumDisplayDevicesW ( LPCWSTR  lpDevice,
DWORD  iDevNum,
PDISPLAY_DEVICEW  lpDisplayDevice,
DWORD  dwFlags 
)

Definition at line 78 of file display.c.

83 {
85  BOOL rc;
86 
87  RtlInitUnicodeString(&Device, lpDevice);
88 
90  &Device,
91  iDevNum,
92  lpDisplayDevice,
93  dwFlags);
94 
95  return rc;
96 }
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
BOOL NTAPI NtUserEnumDisplayDevices(PUNICODE_STRING pustrDevice, DWORD iDevNum, PDISPLAY_DEVICEW pDisplayDevice, DWORD dwFlags)
Definition: display.c:343
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by DisplayOnInit(), fill_display_information_fallback(), InitializeDialog(), InitializeDisplayAdapters(), pCDevSettings_GetMonitorDevice(), pCDevSettings_GetMonitorName(), wined3d_adapter_init(), and wined3d_adapter_init_nogl().

◆ EnumDisplayMonitors()

BOOL WINAPI EnumDisplayMonitors ( HDC  hdc,
LPCRECT  lprcClip,
MONITORENUMPROC  lpfnEnum,
LPARAM  dwData 
)

Definition at line 104 of file display.c.

109 {
110  INT iCount, i;
111  HMONITOR *hMonitorList;
112  LPRECT pRectList;
113  HANDLE hHeap;
114  BOOL ret = FALSE;
115 
116  /* get list of monitors/rects */
117  iCount = NtUserEnumDisplayMonitors(hdc, lprcClip, NULL, NULL, 0);
118  if (iCount < 0)
119  {
120  /* FIXME: SetLastError() */
121  return FALSE;
122  }
123  if (iCount == 0)
124  {
125  return TRUE;
126  }
127 
128  hHeap = GetProcessHeap();
129  hMonitorList = HeapAlloc(hHeap, 0, sizeof (HMONITOR) * iCount);
130  if (hMonitorList == NULL)
131  {
133  return FALSE;
134  }
135  pRectList = HeapAlloc(hHeap, 0, sizeof (RECT) * iCount);
136  if (pRectList == NULL)
137  {
139  goto cleanup;
140  }
141 
142  iCount = NtUserEnumDisplayMonitors(hdc, lprcClip, hMonitorList, pRectList, iCount);
143  if (iCount <= 0)
144  {
145  /* FIXME: SetLastError() */
146  goto cleanup;
147  }
148 
149  /* enumerate list */
150  for (i = 0; i < iCount; i++)
151  {
152  HMONITOR hMonitor = hMonitorList[i];
153  LPRECT pMonitorRect = pRectList + i;
154  HDC hMonitorDC = NULL;
155 
156  if (hdc != NULL)
157  {
158  /* make monitor DC */
159  hMonitorDC = hdc;
160  }
161 
162  if (!lpfnEnum(hMonitor, hMonitorDC, pMonitorRect, dwData))
163  goto cleanup; /* return FALSE */
164  }
165 
166  ret = TRUE;
167 
168 cleanup:
169  if(hMonitorList)
170  HeapFree(hHeap, 0, hMonitorList);
171  if(pRectList)
172  HeapFree(hHeap, 0, pRectList);
173  return ret;
174 }
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
INT NTAPI NtUserEnumDisplayMonitors(OPTIONAL IN HDC hDC, OPTIONAL IN LPCRECT pRect, OPTIONAL OUT HMONITOR *hMonitorList, OPTIONAL OUT LPRECT monitorRectList, OPTIONAL IN DWORD listSize)
int32_t INT
Definition: typedefs.h:56
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
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define SetLastError(x)
Definition: compat.h:409
int ret
HDC hdc
Definition: main.c:9
char * cleanup(char *str)
Definition: wpickclick.c:99
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ EnumDisplaySettingsA()

BOOL WINAPI EnumDisplaySettingsA ( LPCSTR  lpszDeviceName,
DWORD  iModeNum,
LPDEVMODEA  lpDevMode 
)

Definition at line 312 of file display.c.

316 {
317  /* Fixup sizes */
318  lpDevMode->dmSize = FIELD_OFFSET(DEVMODEA, dmICMMethod);
320 
321  return EnumDisplaySettingsExA(lpszDeviceName, iModeNum, lpDevMode, 0);
322 }
WORD dmSize
Definition: wingdi.h:1546
WORD dmDriverExtra
Definition: wingdi.h:1547
static _In_ DWORD iModeNum
Definition: dispmode.c:77
static _In_ DWORD _Inout_ PDEVMODEA lpDevMode
Definition: dispmode.c:77
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
BOOL WINAPI EnumDisplaySettingsExA(LPCSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEA lpDevMode, DWORD dwFlags)
Definition: display.c:182

Referenced by CreateDisplayModeList(), GetAdapterMode(), Notify(), START_TEST(), test_ChangeDisplaySettingsEx(), test_CreateCompatibleDC(), test_EnumDisplaySettings(), test_GdiConvertToDevmodeW(), and test_WM_DISPLAYCHANGE().

◆ EnumDisplaySettingsExA()

BOOL WINAPI EnumDisplaySettingsExA ( LPCSTR  lpszDeviceName,
DWORD  iModeNum,
LPDEVMODEA  lpDevMode,
DWORD  dwFlags 
)

Definition at line 182 of file display.c.

187 {
189  UNICODE_STRING usDeviceName;
190  PUNICODE_STRING pusDeviceName = NULL;
191  LPDEVMODEW lpExtendedDevMode;
192  BOOL Result = FALSE;
193 
194  if (lpszDeviceName)
195  {
196  if (!RtlCreateUnicodeStringFromAsciiz(&usDeviceName, (PCSZ)lpszDeviceName))
197  {
199  return FALSE;
200  }
201  pusDeviceName = &usDeviceName;
202  }
203 
204  /* Allocate memory for DEVMODEW and extra data */
205  lpExtendedDevMode = RtlAllocateHeap(RtlGetProcessHeap(),
207  sizeof(DEVMODEW) + lpDevMode->dmDriverExtra);
208  if (!lpExtendedDevMode)
209  {
210  if (pusDeviceName)
211  RtlFreeUnicodeString(&usDeviceName);
212 
213  return FALSE;
214  }
215 
216  /* Initialize structure fields */
217  lpExtendedDevMode->dmSize = sizeof(DEVMODEW);
218  lpExtendedDevMode->dmDriverExtra = lpDevMode->dmDriverExtra;
219 
220  Status = NtUserEnumDisplaySettings(pusDeviceName, iModeNum, lpExtendedDevMode, dwFlags);
221 
222  if (pusDeviceName)
223  RtlFreeUnicodeString(&usDeviceName);
224 
225  if (NT_SUCCESS(Status))
226  {
227  /* Store old structure size */
228  WORD OldSize = lpDevMode->dmSize;
229 
230 #define COPYS(f,len) WideCharToMultiByte(CP_THREAD_ACP, 0, lpExtendedDevMode->f, len, (LPSTR)lpDevMode->f, len, NULL, NULL)
231 #define COPYN(f) lpDevMode->f = lpExtendedDevMode->f
232 
233  COPYS(dmDeviceName, CCHDEVICENAME);
234  COPYN(dmSpecVersion);
235  COPYN(dmDriverVersion);
236  COPYN(dmFields);
237  COPYN(dmPosition.x);
238  COPYN(dmPosition.y);
239  COPYN(dmScale);
240  COPYN(dmCopies);
241  COPYN(dmDefaultSource);
242  COPYN(dmPrintQuality);
243  COPYN(dmColor);
244  COPYN(dmDuplex);
245  COPYN(dmYResolution);
246  COPYN(dmTTOption);
247  COPYN(dmCollate);
248  COPYS(dmFormName,CCHFORMNAME);
249  COPYN(dmLogPixels);
250  COPYN(dmBitsPerPel);
251  COPYN(dmPelsWidth);
252  COPYN(dmPelsHeight);
253  COPYN(dmDisplayFlags); // aka dmNup
254  COPYN(dmDisplayFrequency);
255 
256  /* we're done with 0x300 fields */
257  if (OldSize > SIZEOF_DEVMODEA_300)
258  {
259  COPYN(dmICMMethod);
260  COPYN(dmICMIntent);
261  COPYN(dmMediaType);
262  COPYN(dmDitherType);
263  COPYN(dmReserved1);
264  COPYN(dmReserved2);
265 
266  /* we're done with 0x400 fields */
267  if (OldSize > SIZEOF_DEVMODEA_400)
268  {
269  COPYN(dmPanningWidth);
270  COPYN(dmPanningHeight);
271  }
272  }
273 
274  /* Restore old size */
275  lpDevMode->dmSize = OldSize;
276 
277  /* Extra data presented? */
278  if (lpDevMode->dmDriverExtra && lpExtendedDevMode->dmDriverExtra)
279  {
280  /* We choose the smallest size */
281  if (lpDevMode->dmDriverExtra > lpExtendedDevMode->dmDriverExtra)
282  lpDevMode->dmDriverExtra = lpExtendedDevMode->dmDriverExtra;
283 
284  /* Copy extra data */
285  RtlCopyMemory((PUCHAR)lpDevMode + OldSize,
286  lpExtendedDevMode + 1,
288  }
289 
290  /* If the size of source structure is less, than used, we clean unsupported flags */
291  if (OldSize < FIELD_OFFSET(DEVMODEA, dmPanningHeight))
293 
294  if (OldSize < FIELD_OFFSET(DEVMODEA, dmPanningWidth))
296 
297  Result = TRUE;
298  }
299 
300  /* Free memory */
301  RtlFreeHeap(RtlGetProcessHeap(), 0, lpExtendedDevMode);
302 
303  return Result;
304 }
CONST char * PCSZ
Definition: umtypes.h:125
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
WORD dmSize
Definition: wingdi.h:1546
WORD dmDriverExtra
Definition: wingdi.h:1547
unsigned char * PUCHAR
Definition: retypes.h:3
#define DM_PANNINGWIDTH
Definition: wingdi.h:1259
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
WORD dmDriverExtra
Definition: wingdi.h:1599
unsigned int BOOL
Definition: ntddk_ex.h:94
#define COPYS(f, len)
static _In_ DWORD iModeNum
Definition: dispmode.c:77
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
static _In_ DWORD _Inout_ PDEVMODEA lpDevMode
Definition: dispmode.c:77
#define SIZEOF_DEVMODEA_300
Definition: display.c:12
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define SIZEOF_DEVMODEA_400
Definition: display.c:13
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS APIENTRY NtUserEnumDisplaySettings(IN PUNICODE_STRING pustrDevice, IN DWORD iModeNum, OUT LPDEVMODEW lpDevMode, IN DWORD dwFlags)
Definition: display.c:565
WORD dmSize
Definition: wingdi.h:1598
unsigned short WORD
Definition: ntddk_ex.h:93
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
DWORD dmFields
Definition: wingdi.h:1548
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CCHFORMNAME
Definition: wingdi.h:67
Status
Definition: gdiplustypes.h:24
#define CCHDEVICENAME
Definition: ddrawi.h:63
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
struct _devicemodeW DEVMODEW
#define DM_PANNINGHEIGHT
Definition: wingdi.h:1260
#define COPYN(f)
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by EnumDisplaySettingsA().

◆ EnumDisplaySettingsExW()

BOOL WINAPI EnumDisplaySettingsExW ( LPCWSTR  lpszDeviceName,
DWORD  iModeNum,
LPDEVMODEW  lpDevMode,
DWORD  dwFlags 
)

Definition at line 330 of file display.c.

335 {
337  UNICODE_STRING usDeviceName;
338  PUNICODE_STRING pusDeviceName = NULL;
339  LPDEVMODEW lpExtendedDevMode;
340  BOOL Result = FALSE;
341 
342  if (lpszDeviceName)
343  {
344  RtlInitUnicodeString(&usDeviceName, lpszDeviceName);
345  pusDeviceName = &usDeviceName;
346  }
347 
348  /* Allocate memory for DEVMODEW and extra data */
349  lpExtendedDevMode = RtlAllocateHeap(RtlGetProcessHeap(),
351  sizeof(DEVMODEW) + lpDevMode->dmDriverExtra);
352  if (!lpExtendedDevMode)
353  return FALSE;
354 
355  /* Initialize structure fields */
356  lpExtendedDevMode->dmSize = sizeof(DEVMODEW);
357  lpExtendedDevMode->dmDriverExtra = lpDevMode->dmDriverExtra;
358 
359  Status = NtUserEnumDisplaySettings(pusDeviceName, iModeNum, lpExtendedDevMode, dwFlags);
360  if (NT_SUCCESS(Status))
361  {
362  /* Store old structure sizes */
363  WORD OldSize = lpDevMode->dmSize;
364  WORD OldDriverExtra = lpDevMode->dmDriverExtra;
365 
366  /* Copy general data */
367  RtlCopyMemory(lpDevMode, lpExtendedDevMode, OldSize);
368 
369  /* Restore old sizes */
370  lpDevMode->dmSize = OldSize;
371  lpDevMode->dmDriverExtra = OldDriverExtra;
372 
373  /* Extra data presented? */
374  if (lpDevMode->dmDriverExtra && lpExtendedDevMode->dmDriverExtra)
375  {
376  /* We choose the smallest size */
377  if (lpDevMode->dmDriverExtra > lpExtendedDevMode->dmDriverExtra)
378  lpDevMode->dmDriverExtra = lpExtendedDevMode->dmDriverExtra;
379 
380  /* Copy extra data */
381  RtlCopyMemory((PUCHAR)lpDevMode + OldSize,
382  lpExtendedDevMode + 1,
384  }
385 
386  /* If the size of source structure is less, than used, we clean unsupported flags */
387  if (OldSize < FIELD_OFFSET(DEVMODEW, dmPanningHeight))
389 
390  if (OldSize < FIELD_OFFSET(DEVMODEW, dmPanningWidth))
392 
393  Result = TRUE;
394  }
395 
396  /* Free memory */
397  RtlFreeHeap(RtlGetProcessHeap(), 0, lpExtendedDevMode);
398 
399  return Result;
400 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
WORD dmSize
Definition: wingdi.h:1546
WORD dmDriverExtra
Definition: wingdi.h:1547
unsigned char * PUCHAR
Definition: retypes.h:3
#define DM_PANNINGWIDTH
Definition: wingdi.h:1259
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
WORD dmDriverExtra
Definition: wingdi.h:1599
unsigned int BOOL
Definition: ntddk_ex.h:94
static _In_ DWORD iModeNum
Definition: dispmode.c:77
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
static _In_ DWORD _Inout_ PDEVMODEA lpDevMode
Definition: dispmode.c:77
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS APIENTRY NtUserEnumDisplaySettings(IN PUNICODE_STRING pustrDevice, IN DWORD iModeNum, OUT LPDEVMODEW lpDevMode, IN DWORD dwFlags)
Definition: display.c:565
WORD dmSize
Definition: wingdi.h:1598
unsigned short WORD
Definition: ntddk_ex.h:93
DWORD dmFields
Definition: wingdi.h:1548
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Status
Definition: gdiplustypes.h:24
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _devicemodeW DEVMODEW
#define DM_PANNINGHEIGHT
Definition: wingdi.h:1260

Referenced by EnumDisplaySettingsW(), GetPossibleSettings(), wined3d_enum_adapter_modes(), wined3d_get_adapter_display_mode(), and wined3d_get_adapter_mode_count().

◆ EnumDisplaySettingsW()

BOOL WINAPI EnumDisplaySettingsW ( LPCWSTR  lpszDeviceName,
DWORD  iModeNum,
LPDEVMODEW  lpDevMode 
)

Definition at line 408 of file display.c.

412 {
413  /* Fixup sizes */
414  lpDevMode->dmSize = FIELD_OFFSET(DEVMODEW, dmICMMethod);
416 
417  return EnumDisplaySettingsExW(lpszDeviceName, iModeNum, lpDevMode, 0);
418 }
WORD dmSize
Definition: wingdi.h:1546
WORD dmDriverExtra
Definition: wingdi.h:1547
static _In_ DWORD iModeNum
Definition: dispmode.c:77
static _In_ DWORD _Inout_ PDEVMODEA lpDevMode
Definition: dispmode.c:77
BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode, DWORD dwFlags)
Definition: display.c:330
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254

Referenced by GetSystemColorDepth(), InitializeDialog(), ProcessUnattendSection(), START_TEST(), and wined3d_set_adapter_display_mode().

◆ GetMonitorInfoA()

BOOL WINAPI GetMonitorInfoA ( HMONITOR  hMonitor,
LPMONITORINFO  lpmi 
)

Definition at line 426 of file display.c.

429 {
430  if (lpmi->cbSize == sizeof (MONITORINFO))
431  {
432  return NtUserGetMonitorInfo(hMonitor, lpmi);
433  }
434  else if (lpmi->cbSize != sizeof (MONITORINFOEXA))
435  {
437  return FALSE;
438  }
439  else
440  {
441  MONITORINFOEXW miExW;
442  INT res;
443 
444  miExW.cbSize = sizeof (MONITORINFOEXW);
445  if (!NtUserGetMonitorInfo(hMonitor, (LPMONITORINFO)&miExW))
446  {
447  return FALSE;
448  }
449  memcpy(lpmi, &miExW, sizeof (MONITORINFO));
450  res = WideCharToMultiByte(CP_THREAD_ACP, 0, miExW.szDevice, -1,
451  ((LPMONITORINFOEXA)lpmi)->szDevice, CCHDEVICENAME,
452  NULL, NULL);
453  if (res == 0)
454  {
455  WARN("WideCharToMultiByte() failed!\n");
456  return FALSE;
457  }
458  }
459 
460  return TRUE;
461 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define WideCharToMultiByte
Definition: compat.h:101
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define WARN(fmt,...)
Definition: debug.h:111
BOOL NTAPI NtUserGetMonitorInfo(IN HMONITOR hMonitor, OUT LPMONITORINFO pMonitorInfo)
Definition: monitor.c:728
int32_t INT
Definition: typedefs.h:56
struct tagMONITORINFOEXW MONITORINFOEXW
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CCHDEVICENAME
Definition: ddrawi.h:63
DWORD cbSize
Definition: winuser.h:3726
GLuint res
Definition: glext.h:9613
#define CP_THREAD_ACP
Definition: winnls.h:230

◆ GetMonitorInfoW()

BOOL WINAPI GetMonitorInfoW ( HMONITOR  hMonitor,
LPMONITORINFO  lpmi 
)

Definition at line 469 of file display.c.

472 {
473  return NtUserGetMonitorInfo(hMonitor, lpmi);
474 }
BOOL NTAPI NtUserGetMonitorInfo(IN HMONITOR hMonitor, OUT LPMONITORINFO pMonitorInfo)
Definition: monitor.c:728

◆ MonitorFromPoint()

HMONITOR WINAPI MonitorFromPoint ( IN POINT  ptPoint,
IN DWORD  dwFlags 
)

Definition at line 482 of file display.c.

485 {
486  return NtUserMonitorFromPoint(ptPoint, dwFlags);
487 }
HMONITOR NTAPI NtUserMonitorFromPoint(IN POINT point, IN DWORD dwFlags)
Definition: monitor.c:827
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

◆ MonitorFromRect()

HMONITOR WINAPI MonitorFromRect ( IN LPCRECT  lpcRect,
IN DWORD  dwFlags 
)

Definition at line 495 of file display.c.

498 {
499  return NtUserMonitorFromRect(lpcRect, dwFlags);
500 }
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HMONITOR NTAPI NtUserMonitorFromRect(IN LPCRECT pRect, IN DWORD dwFlags)

◆ MonitorFromWindow()

HMONITOR WINAPI MonitorFromWindow ( IN HWND  hWnd,
IN DWORD  dwFlags 
)

Definition at line 508 of file display.c.

511 {
513 }
HWND hWnd
Definition: settings.c:17
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HMONITOR NTAPI NtUserMonitorFromWindow(IN HWND hWnd, IN DWORD dwFlags)
Definition: monitor.c:967

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( user32  )