diff --git a/reactos/subsystems/win32/win32k/objects/wingl.c b/reactos/subsystems/win32/win32k/objects/wingl.c index de7781f87f2..6d32b319741 100644 --- a/reactos/subsystems/win32/win32k/objects/wingl.c +++ b/reactos/subsystems/win32/win32k/objects/wingl.c @@ -23,13 +23,32 @@ #define NDEBUG #include +static INT -APIENTRY -NtGdiChoosePixelFormat(HDC hDC, - CONST PPIXELFORMATDESCRIPTOR pfd) +FASTCALL +IntGetipfdDevMax(PDC pdc) { - UNIMPLEMENTED; - return 0; + INT Ret = 0; + PPDEVOBJ ppdev = pdc->ppdev; + + if (ppdev->flFlags & PDEV_META_DEVICE) + { + return 0; + } + + if (ppdev->DriverFunctions.DescribePixelFormat) + { + + Ret = ppdev->DriverFunctions.DescribePixelFormat( + ppdev->hPDev, + 1, + 0, + NULL); + } + + if (Ret) pdc->ipfdDevMax = Ret; + + return Ret; } @@ -40,8 +59,67 @@ NtGdiDescribePixelFormat(HDC hDC, UINT BufSize, LPPIXELFORMATDESCRIPTOR pfd) { - UNIMPLEMENTED; - return 0; + PDC pdc; + PPDEVOBJ ppdev; + INT Ret = 0; + PIXELFORMATDESCRIPTOR pfdSafe; + NTSTATUS Status = STATUS_SUCCESS; + + if (!BufSize) return 0; + + pdc = DC_LockDc(hDC); + if (!pdc) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + return 0; + } + + if (!pdc->ipfdDevMax) IntGetipfdDevMax(pdc); + + if ( BufSize < sizeof(PIXELFORMATDESCRIPTOR) || + PixelFormat < 1 || + PixelFormat > pdc->ipfdDevMax ) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + goto Exit; + } + + ppdev = pdc->ppdev; + + if (ppdev->flFlags & PDEV_META_DEVICE) + { + UNIMPLEMENTED; + goto Exit; + } + + if (ppdev->DriverFunctions.DescribePixelFormat) + { + + Ret = ppdev->DriverFunctions.DescribePixelFormat( + ppdev->hPDev, + PixelFormat, + sizeof(PIXELFORMATDESCRIPTOR), + &pfdSafe); + } + + _SEH2_TRY + { + ProbeForWrite( pfd, + sizeof(PIXELFORMATDESCRIPTOR), + 1); + RtlCopyMemory(&pfdSafe, pfd, sizeof(PIXELFORMATDESCRIPTOR)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + + if (!NT_SUCCESS(Status)) SetLastNtError(Status); + +Exit: + DC_UnlockDc(pdc); + return Ret; }