Index: win32ss/gdi/ntgdi/palette.c =================================================================== --- win32ss/gdi/ntgdi/palette.c (revision 58292) +++ win32ss/gdi/ntgdi/palette.c (working copy) @@ -756,44 +756,53 @@ FASTCALL IntGdiRealizePalette(HDC hDC) { - UINT i, realize = 0; - PDC pdc; - PALETTE *ppalSurf, *ppalDC; + /* This patch is just a Revert. To check if the problem is related to a bad handle of the Palette + * This function doesn't do any real work now and there's plenty + * of bugs in it. + */ + PPALETTE palGDI, sysGDI; + int realized = 0; + PDC dc; + HPALETTE systemPalette; + dc = DC_LockDc(hDC); + if (!dc) return 0; + systemPalette = NtGdiGetStockObject(DEFAULT_PALETTE); + palGDI = PALETTE_LockPalette(dc->dclevel.hpal); + if (palGDI == NULL) + { + DPRINT1("IntGdiRealizePalette(): palGDI is NULL, exiting\n"); + DC_UnlockDc(dc); + return 0; + } + sysGDI = PALETTE_LockPalette(systemPalette); + if (sysGDI == NULL) + { + DPRINT1("IntGdiRealizePalette(): sysGDI is NULL, exiting\n"); + PALETTE_UnlockPalette(palGDI); + DC_UnlockDc(dc); + return 0; + } + + // The RealizePalette function modifies the palette for the device associated with the specified device context. If the + // device context is a memory DC, the color table for the bitmap selected into the DC is modified. If the device + // context is a display DC, the physical palette for that device is modified. + if(dc->dctype == DC_TYPE_MEMORY) + { + // Memory managed DC + DPRINT1("RealizePalette unimplemented for memory managed DCs\n"); + } else + { + DPRINT1("RealizePalette unimplemented for device DCs\n"); + } + + // need to pass this to IntEngCreateXlate with palettes unlocked + PALETTE_UnlockPalette(sysGDI); + PALETTE_UnlockPalette(palGDI); + + DC_UnlockDc(dc); + + return realized; - pdc = DC_LockDc(hDC); - if(!pdc) - { - EngSetLastError(ERROR_INVALID_HANDLE); - return 0; - } - - if (!pdc->dclevel.pSurface) - { - goto cleanup; - } - - ppalSurf = pdc->dclevel.pSurface->ppal; - ppalDC = pdc->dclevel.ppal; - - if(!(ppalSurf->flFlags & PAL_INDEXED)) - { - // FIXME: Set error? - goto cleanup; - } - - ASSERT(ppalDC->flFlags & PAL_INDEXED); - - // FIXME: Should we resize ppalSurf if it's too small? - realize = (ppalDC->NumColors < ppalSurf->NumColors) ? ppalDC->NumColors : ppalSurf->NumColors; - - for(i=0; iIndexedColors[i], *(LONG*)&ppalDC->IndexedColors[i]); - } - -cleanup: - DC_UnlockDc(pdc); - return realize; } UINT APIENTRY