https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c698eff041ef60bab147f9...
commit c698eff041ef60bab147f9feae57fab816327984 Author: jimtabor james.tabor@reactos.org AuthorDate: Tue Sep 3 14:36:20 2019 -0500 Commit: jimtabor james.tabor@reactos.org CommitDate: Tue Sep 3 14:36:20 2019 -0500
[Win32SS] Implement EngCreate/DeletePalette.
Safe to be called from user side without UMPD support. --- win32ss/gdi/eng/umpdstubs.c | 25 -------------------- win32ss/gdi/ntgdi/palette.c | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 25 deletions(-)
diff --git a/win32ss/gdi/eng/umpdstubs.c b/win32ss/gdi/eng/umpdstubs.c index acb280ff273..de2a2c6e0e5 100644 --- a/win32ss/gdi/eng/umpdstubs.c +++ b/win32ss/gdi/eng/umpdstubs.c @@ -211,21 +211,6 @@ NtGdiEngCreateDeviceSurface( return NULL; }
-__kernel_entry -HPALETTE -APIENTRY -NtGdiEngCreatePalette( - _In_ ULONG iMode, - _In_ ULONG cColors, - _In_ ULONG *pulColors, - _In_ FLONG flRed, - _In_ FLONG flGreen, - _In_ FLONG flBlue) -{ - UNIMPLEMENTED; - return NULL; -} - __kernel_entry NTSTATUS APIENTRY @@ -236,16 +221,6 @@ NtGdiEngDeleteClip( return STATUS_NOT_IMPLEMENTED; }
-__kernel_entry -BOOL -APIENTRY -NtGdiEngDeletePalette( - _In_ HPALETTE hPal) -{ - UNIMPLEMENTED; - return FALSE; -} - __kernel_entry NTSTATUS APIENTRY diff --git a/win32ss/gdi/ntgdi/palette.c b/win32ss/gdi/ntgdi/palette.c index ef4509153e6..18234566ee9 100644 --- a/win32ss/gdi/ntgdi/palette.c +++ b/win32ss/gdi/ntgdi/palette.c @@ -12,6 +12,9 @@ #define NDEBUG #include <debug.h>
+#define PAL_SETOWNER 0x8000 +#define MAX_PALCOLORS 65536 + static UINT SystemPaletteUse = SYSPAL_NOSTATIC; /* The program need save the pallete and restore it */
PALETTE gpalRGB, gpalBGR, gpalRGB555, gpalRGB565, *gppalMono, *gppalDefault; @@ -1263,5 +1266,58 @@ NtGdiUnrealizeObject(HGDIOBJ hgdiobj) return Ret; }
+__kernel_entry +HPALETTE +APIENTRY +NtGdiEngCreatePalette( + _In_ ULONG iMode, + _In_ ULONG cColors, + _In_ ULONG *pulColors, + _In_ FLONG flRed, + _In_ FLONG flGreen, + _In_ FLONG flBlue) +{ + HPALETTE hPal = NULL; + ULONG *pulcSafe, ulColors[WINDDI_MAXSETPALETTECOLORS]; + + if ( cColors > MAX_PALCOLORS ) return NULL; + + if ( cColors <= WINDDI_MAXSETPALETTECOLORS ) + { + pulcSafe = ulColors; + } + else + { + pulcSafe = ExAllocatePoolWithTag(PagedPool, cColors * sizeof(ULONG), GDITAG_UMPD ); + } + + _SEH2_TRY + { + ProbeForRead( pulColors, cColors * sizeof(ULONG), 1); + RtlCopyMemory( pulcSafe, pulColors, cColors * sizeof(ULONG) ); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + SetLastNtError(_SEH2_GetExceptionCode()); + if ( cColors > WINDDI_MAXSETPALETTECOLORS ) ExFreePoolWithTag( pulcSafe, GDITAG_UMPD ); + _SEH2_YIELD(return hPal); + } + _SEH2_END; + + hPal = EngCreatePalette( iMode/*|PAL_SETOWNER*/, cColors, pulColors, flRed, flGreen, flBlue ); + + if ( cColors > WINDDI_MAXSETPALETTECOLORS ) ExFreePoolWithTag( pulcSafe, GDITAG_UMPD ); + + return hPal; +} + +__kernel_entry +BOOL +APIENTRY +NtGdiEngDeletePalette( + _In_ HPALETTE hPal) +{ + return EngDeletePalette(hPal); +}
/* EOF */