2008-05-11 23:51:55 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: subsystems/win32/win32k/ntuser/display.c
|
|
|
|
* PURPOSE: display settings
|
|
|
|
* COPYRIGHT: Copyright 2007 ReactOS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2008-05-11 23:51:55 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#define SIZEOF_DEVMODEW_300 188
|
|
|
|
#define SIZEOF_DEVMODEW_400 212
|
|
|
|
#define SIZEOF_DEVMODEW_500 220
|
|
|
|
|
|
|
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
|
|
|
|
|
|
|
NTSTATUS
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2008-05-11 23:51:55 +00:00
|
|
|
NtUserEnumDisplaySettings(
|
|
|
|
PUNICODE_STRING pusDeviceName,
|
|
|
|
DWORD iModeNum,
|
|
|
|
LPDEVMODEW lpDevMode, /* FIXME is this correct? */
|
|
|
|
DWORD dwFlags )
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
LPDEVMODEW pSafeDevMode;
|
|
|
|
PUNICODE_STRING pusSafeDeviceName = NULL;
|
|
|
|
UNICODE_STRING usSafeDeviceName;
|
|
|
|
USHORT Size = 0, ExtraSize = 0;
|
|
|
|
|
|
|
|
/* Copy the devmode */
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2008-05-11 23:51:55 +00:00
|
|
|
{
|
|
|
|
ProbeForRead(lpDevMode, sizeof(DEVMODEW), 1);
|
|
|
|
Size = lpDevMode->dmSize;
|
|
|
|
ExtraSize = lpDevMode->dmDriverExtra;
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2008-05-11 23:51:55 +00:00
|
|
|
{
|
|
|
|
DPRINT("FIXME ? : Out of range of DEVMODEW size \n");
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2008-05-11 23:51:55 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2008-05-11 23:51:55 +00:00
|
|
|
|
|
|
|
if (Size != sizeof(DEVMODEW))
|
|
|
|
{
|
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
2010-06-10 19:58:39 +00:00
|
|
|
pSafeDevMode = ExAllocatePoolWithTag(PagedPool, Size + ExtraSize, GDITAG_DEVMODE);
|
2008-05-11 23:51:55 +00:00
|
|
|
if (pSafeDevMode == NULL)
|
|
|
|
{
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
pSafeDevMode->dmSize = Size;
|
|
|
|
pSafeDevMode->dmDriverExtra = ExtraSize;
|
|
|
|
|
|
|
|
/* Copy the device name */
|
|
|
|
if (pusDeviceName != NULL)
|
|
|
|
{
|
|
|
|
Status = IntSafeCopyUnicodeString(&usSafeDeviceName, pusDeviceName);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
ExFreePool(pSafeDevMode);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
pusSafeDeviceName = &usSafeDeviceName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call internal function */
|
|
|
|
Status = IntEnumDisplaySettings(pusSafeDeviceName, iModeNum, pSafeDevMode, dwFlags);
|
|
|
|
|
|
|
|
if (pusSafeDeviceName != NULL)
|
|
|
|
RtlFreeUnicodeString(pusSafeDeviceName);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
ExFreePool(pSafeDevMode);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy some information back */
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2008-05-11 23:51:55 +00:00
|
|
|
{
|
|
|
|
ProbeForWrite(lpDevMode,Size + ExtraSize, 1);
|
|
|
|
lpDevMode->dmPelsWidth = pSafeDevMode->dmPelsWidth;
|
|
|
|
lpDevMode->dmPelsHeight = pSafeDevMode->dmPelsHeight;
|
|
|
|
lpDevMode->dmBitsPerPel = pSafeDevMode->dmBitsPerPel;
|
|
|
|
lpDevMode->dmDisplayFrequency = pSafeDevMode->dmDisplayFrequency;
|
|
|
|
lpDevMode->dmDisplayFlags = pSafeDevMode->dmDisplayFlags;
|
|
|
|
|
|
|
|
/* output private/extra driver data */
|
|
|
|
if (ExtraSize > 0)
|
|
|
|
{
|
|
|
|
memcpy((PCHAR)lpDevMode + Size, (PCHAR)pSafeDevMode + Size, ExtraSize);
|
|
|
|
}
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2008-05-11 23:51:55 +00:00
|
|
|
{
|
2008-11-30 19:28:11 +00:00
|
|
|
Status = _SEH2_GetExceptionCode();
|
2008-05-11 23:51:55 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2008-05-11 23:51:55 +00:00
|
|
|
|
|
|
|
ExFreePool(pSafeDevMode);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LONG
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2008-05-11 23:51:55 +00:00
|
|
|
NtUserChangeDisplaySettings(
|
|
|
|
PUNICODE_STRING lpszDeviceName,
|
|
|
|
LPDEVMODEW lpDevMode,
|
|
|
|
HWND hwnd,
|
|
|
|
DWORD dwflags,
|
|
|
|
LPVOID lParam)
|
|
|
|
{
|
2009-08-07 12:10:59 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
LPDEVMODEW lpSafeDevMode = NULL;
|
2008-05-11 23:51:55 +00:00
|
|
|
DEVMODEW DevMode;
|
|
|
|
PUNICODE_STRING pSafeDeviceName = NULL;
|
|
|
|
UNICODE_STRING SafeDeviceName;
|
|
|
|
LONG Ret;
|
|
|
|
|
|
|
|
/* Check arguments */
|
|
|
|
#ifdef CDS_VIDEOPARAMETERS
|
2009-08-08 19:53:21 +00:00
|
|
|
if (dwflags != CDS_VIDEOPARAMETERS && lParam != NULL)
|
2008-05-11 23:51:55 +00:00
|
|
|
#else
|
2009-08-08 19:53:21 +00:00
|
|
|
if (lParam != NULL)
|
2008-05-11 23:51:55 +00:00
|
|
|
#endif
|
2009-08-08 19:53:21 +00:00
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
|
|
|
return DISP_CHANGE_BADPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hwnd != NULL)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
|
|
|
return DISP_CHANGE_BADPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy devmode */
|
|
|
|
if (lpDevMode != NULL)
|
|
|
|
{
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForRead(lpDevMode, sizeof(DevMode.dmSize), 1);
|
|
|
|
DevMode.dmSize = lpDevMode->dmSize;
|
|
|
|
DevMode.dmSize = min(sizeof(DevMode), DevMode.dmSize);
|
|
|
|
ProbeForRead(lpDevMode, DevMode.dmSize, 1);
|
|
|
|
RtlCopyMemory(&DevMode, lpDevMode, DevMode.dmSize);
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
return DISP_CHANGE_BADPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DevMode.dmDriverExtra > 0)
|
|
|
|
{
|
|
|
|
DPRINT1("lpDevMode->dmDriverExtra is IGNORED!\n");
|
|
|
|
DevMode.dmDriverExtra = 0;
|
|
|
|
}
|
|
|
|
lpSafeDevMode = &DevMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy the device name */
|
|
|
|
if (lpszDeviceName != NULL)
|
|
|
|
{
|
|
|
|
Status = IntSafeCopyUnicodeString(&SafeDeviceName, lpszDeviceName);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
return DISP_CHANGE_BADPARAM;
|
|
|
|
}
|
|
|
|
pSafeDeviceName = &SafeDeviceName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call internal function */
|
|
|
|
Ret = IntChangeDisplaySettings(pSafeDeviceName, lpSafeDevMode, dwflags, lParam);
|
|
|
|
|
|
|
|
if (pSafeDeviceName != NULL)
|
|
|
|
RtlFreeUnicodeString(pSafeDeviceName);
|
2008-05-11 23:51:55 +00:00
|
|
|
|
2009-08-08 19:53:21 +00:00
|
|
|
return Ret;
|
2008-05-11 23:51:55 +00:00
|
|
|
}
|
|
|
|
|