mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[WIN32K] CreateDIBPalette SEH Simplification #3758 CORE-17626
Enter an SEH2_TRY one time and do all testing within it instead of entering the SEH_TRY multiple times.
The commit is an addendum to 0.4.15-dev-2734-g 514147776a
Thanks to patches author Doug-Lyons
This is 1:1 the final approved content of #3758, but I committed
by hand and closed the PR to avoid squash+rebase.
This commit is contained in:
parent
c8ce0cc434
commit
c596fd3ef6
1 changed files with 17 additions and 24 deletions
|
@ -45,8 +45,6 @@ CreateDIBPalette(
|
||||||
{
|
{
|
||||||
PPALETTE ppal;
|
PPALETTE ppal;
|
||||||
ULONG i, cBitsPixel, cColors;
|
ULONG i, cBitsPixel, cColors;
|
||||||
RGBQUAD rgb;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
if (pbmi->bmiHeader.biSize < sizeof(BITMAPINFOHEADER))
|
if (pbmi->bmiHeader.biSize < sizeof(BITMAPINFOHEADER))
|
||||||
{
|
{
|
||||||
|
@ -129,34 +127,29 @@ CreateDIBPalette(
|
||||||
{
|
{
|
||||||
/* The colors are an array of RGBQUAD values */
|
/* The colors are an array of RGBQUAD values */
|
||||||
RGBQUAD *prgb = (RGBQUAD*)((PCHAR)pbmi + pbmi->bmiHeader.biSize);
|
RGBQUAD *prgb = (RGBQUAD*)((PCHAR)pbmi + pbmi->bmiHeader.biSize);
|
||||||
|
RGBQUAD colors[256] = {0};
|
||||||
|
|
||||||
// FIXME: do we need to handle PALETTEINDEX / PALETTERGB macro?
|
// FIXME: do we need to handle PALETTEINDEX / PALETTERGB macro?
|
||||||
|
|
||||||
/* Loop all color indices in the DIB */
|
/* Use SEH to verify we can READ prgb[] succesfully */
|
||||||
for (i = 0; i < cColors; i++)
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
/* User SEH to verify READ success */
|
RtlCopyMemory(colors, prgb, cColors * sizeof(colors[0]));
|
||||||
Status = STATUS_SUCCESS;
|
}
|
||||||
_SEH2_TRY
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
rgb = prgb[i];
|
/* Do Nothing */
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_END;
|
||||||
{
|
|
||||||
Status = _SEH2_GetExceptionCode();
|
|
||||||
/* On Read Failure, put zero in Palette */
|
|
||||||
PALETTE_vSetRGBColorForIndex(ppal, i, 0);
|
|
||||||
}
|
|
||||||
_SEH2_END
|
|
||||||
|
|
||||||
if(NT_SUCCESS(Status))
|
for (i = 0; i < cColors; ++i)
|
||||||
{
|
{
|
||||||
/* Get the color value and translate it to a COLORREF */
|
/* Get the color value and translate it to a COLORREF */
|
||||||
COLORREF crColor = RGB(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue);
|
COLORREF crColor = RGB(colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue);
|
||||||
|
|
||||||
|
/* Set the RGB value in the palette */
|
||||||
|
PALETTE_vSetRGBColorForIndex(ppal, i, crColor);
|
||||||
|
|
||||||
/* Set the RGB value in the palette */
|
|
||||||
PALETTE_vSetRGBColorForIndex(ppal, i, crColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue