[NTGDI] Fix MaskBlt error code and check pattern usage (#7083)

Follow-up to #7074. Fix MaskBlt behaviour.
JIRA issue: CORE-13133
- Fix MaskBlt error code.
- Fix MaskBlt pattern usage check.
This commit is contained in:
Katayama Hirofumi MZ 2024-07-06 13:28:26 +09:00 committed by GitHub
parent c536664666
commit 61cdd02d1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -337,18 +337,22 @@ NtGdiMaskBlt(
BOOL Status = FALSE; BOOL Status = FALSE;
EXLATEOBJ exlo; EXLATEOBJ exlo;
XLATEOBJ *XlateObj = NULL; XLATEOBJ *XlateObj = NULL;
BOOL UsesSource; BOOL UsesSource, UsesPattern;
ROP4 rop4; ROP4 rop4;
rop4 = WIN32_ROP4_TO_ENG_ROP4(dwRop4); rop4 = WIN32_ROP4_TO_ENG_ROP4(dwRop4);
UsesSource = ROP4_USES_SOURCE(rop4); if (!hdcDest)
if (!hdcDest || (UsesSource && !hdcSrc))
{ {
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
} }
UsesSource = ROP4_USES_SOURCE(rop4);
UsesPattern = ROP4_USES_PATTERN(rop4);
if (!hdcSrc && (UsesSource || UsesPattern))
return FALSE;
/* Check if we need a mask and have a mask bitmap */ /* Check if we need a mask and have a mask bitmap */
if (ROP4_USES_MASK(rop4) && (hbmMask != NULL)) if (ROP4_USES_MASK(rop4) && (hbmMask != NULL))
{ {
@ -363,8 +367,8 @@ NtGdiMaskBlt(
/* Make sure the mask bitmap is 1 BPP */ /* Make sure the mask bitmap is 1 BPP */
if (gajBitsPerFormat[psurfMask->SurfObj.iBitmapFormat] != 1) if (gajBitsPerFormat[psurfMask->SurfObj.iBitmapFormat] != 1)
{ {
EngSetLastError(ERROR_INVALID_PARAMETER);
SURFACE_ShareUnlockSurface(psurfMask); SURFACE_ShareUnlockSurface(psurfMask);
EngSetLastError(ERROR_INVALID_HANDLE);
return FALSE; return FALSE;
} }
} }
@ -398,6 +402,7 @@ NtGdiMaskBlt(
if(DCSrc) DC_UnlockDc(DCSrc); if(DCSrc) DC_UnlockDc(DCSrc);
WARN("Invalid destination dc handle (0x%p) passed to NtGdiMaskBlt\n", hdcDest); WARN("Invalid destination dc handle (0x%p) passed to NtGdiMaskBlt\n", hdcDest);
if(psurfMask) SURFACE_ShareUnlockSurface(psurfMask); if(psurfMask) SURFACE_ShareUnlockSurface(psurfMask);
EngSetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
} }
@ -533,6 +538,9 @@ cleanup:
DC_UnlockDc(DCDest); DC_UnlockDc(DCDest);
if(psurfMask) SURFACE_ShareUnlockSurface(psurfMask); if(psurfMask) SURFACE_ShareUnlockSurface(psurfMask);
if (!Status)
EngSetLastError(ERROR_INVALID_PARAMETER);
return Status; return Status;
} }