diff --git a/win32ss/gdi/eng/pdevobj.h b/win32ss/gdi/eng/pdevobj.h index 9b986ac..4fabfe1 100644 --- a/win32ss/gdi/eng/pdevobj.h +++ b/win32ss/gdi/eng/pdevobj.h @@ -201,11 +201,4 @@ PDEVOBJ_pdmMatchDevMode( PPDEVOBJ ppdev, PDEVMODEW pdm); -FORCEINLINE -VOID -PDEVOBJ_vReference(PPDEVOBJ ppdev) -{ - InterlockedIncrement(&ppdev->cPdevRefs); -} - #endif /* !__WIN32K_PDEVOBJ_H */ diff --git a/win32ss/gdi/eng/surface.h b/win32ss/gdi/eng/surface.h index e65ff12..b415d67 100644 --- a/win32ss/gdi/eng/surface.h +++ b/win32ss/gdi/eng/surface.h @@ -90,13 +90,6 @@ enum _SURFACEFLAGS /* NOTE: Use shared locks! */ #define SURFACE_ShareLockSurface(hBMObj) \ ((PSURFACE) GDIOBJ_ShareLockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)) -FORCEINLINE -VOID -SURFACE_ShareLockByPointer(PSURFACE psurf) -{ - GDIOBJ_vReferenceObjectByPointer(&psurf->BaseObject); -} - #define SURFACE_UnlockSurface(pBMObj) \ GDIOBJ_vUnlockObject ((POBJ)pBMObj) #define SURFACE_ShareUnlockSurface(pBMObj) \ diff --git a/win32ss/gdi/ntgdi/print.c b/win32ss/gdi/ntgdi/print.c index 582bfca..5139eaa 100644 --- a/win32ss/gdi/ntgdi/print.c +++ b/win32ss/gdi/ntgdi/print.c @@ -77,6 +77,43 @@ NtGdiEscape(HDC hDC, INT APIENTRY +IntGdiExtEscape( + PDC dc, + INT Escape, + INT InSize, + LPCSTR InData, + INT OutSize, + LPSTR OutData) +{ + SURFACE *psurf; + INT Result; + + if ((dc->ppdev->DriverFunctions.Escape == NULL) || + (dc->dclevel.pSurface == NULL)) + { + Result = 0; + } + else + { + DC_vPrepareDCsForBlit(dc, NULL, NULL, NULL); + psurf = dc->dclevel.pSurface; + + Result = dc->ppdev->DriverFunctions.Escape( + &psurf->SurfObj, + Escape, + InSize, + (PVOID)InData, + OutSize, + (PVOID)OutData ); + + DC_vFinishBlit(dc, NULL); + } + + return Result; +} + +INT +APIENTRY NtGdiExtEscape( HDC hDC, IN OPTIONAL PWCHAR pDriver, @@ -87,73 +124,22 @@ NtGdiExtEscape( INT OutSize, OPTIONAL LPSTR UnsafeOutData) { + PDC pDC; LPVOID SafeInData = NULL; LPVOID SafeOutData = NULL; NTSTATUS Status = STATUS_SUCCESS; INT Result; - PPDEVOBJ ppdev; - PSURFACE psurf; - - if (hDC == NULL) - { - if (pDriver) - { - /* FIXME : Get the pdev from its name */ - UNIMPLEMENTED; - return -1; - } - ppdev = EngpGetPDEV(NULL); - if (!ppdev) - { - EngSetLastError(ERROR_BAD_DEVICE); - return -1; - } - - /* We're using the primary surface of the pdev. Lock it */ - EngAcquireSemaphore(ppdev->hsemDevLock); - - psurf = ppdev->pSurface; - if (!psurf) - { - EngReleaseSemaphore(ppdev->hsemDevLock); - PDEVOBJ_vRelease(ppdev); - return 0; - } - SURFACE_ShareLockByPointer(psurf); - } - else + if (hDC == 0) { - PDC pDC = DC_LockDc(hDC); - if ( pDC == NULL ) - { - EngSetLastError(ERROR_INVALID_HANDLE); - return -1; - } - - /* Get the PDEV from the DC */ - ppdev = pDC->ppdev; - PDEVOBJ_vReference(ppdev); - - /* Check if we have a surface */ - psurf = pDC->dclevel.pSurface; - if (!psurf) - { - DC_UnlockDc(pDC); - PDEVOBJ_vRelease(ppdev); - return 0; - } - SURFACE_ShareLockByPointer(psurf); - - /* We're done with the DC */ - DC_UnlockDc(pDC); + hDC = UserGetWindowDC(NULL); } - /* See if we actually have a driver function to call */ - if (ppdev->DriverFunctions.Escape == NULL) + pDC = DC_LockDc(hDC); + if ( pDC == NULL ) { - Result = 0; - goto Exit; + EngSetLastError(ERROR_INVALID_HANDLE); + return -1; } if ( InSize && UnsafeInData ) @@ -172,16 +158,17 @@ NtGdiExtEscape( if (!NT_SUCCESS(Status)) { - Result = -1; - goto Exit; + DC_UnlockDc(pDC); + SetLastNtError(Status); + return -1; } SafeInData = ExAllocatePoolWithTag ( PagedPool, InSize, GDITAG_TEMP ); if ( !SafeInData ) { + DC_UnlockDc(pDC); EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); - Result = -1; - goto Exit; + return -1; } _SEH2_TRY @@ -199,9 +186,10 @@ NtGdiExtEscape( if ( !NT_SUCCESS(Status) ) { + ExFreePoolWithTag ( SafeInData, GDITAG_TEMP ); + DC_UnlockDc(pDC); SetLastNtError(Status); - Result = -1; - goto Exit; + return -1; } } @@ -221,65 +209,50 @@ NtGdiExtEscape( if (!NT_SUCCESS(Status)) { - SetLastNtError(Status); - Result = -1; - goto Exit; + SetLastNtError(Status); + goto freeout; } SafeOutData = ExAllocatePoolWithTag ( PagedPool, OutSize, GDITAG_TEMP ); if ( !SafeOutData ) { EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); - Result = -1; - goto Exit; +freeout: + if ( SafeInData ) + ExFreePoolWithTag ( SafeInData, GDITAG_TEMP ); + DC_UnlockDc(pDC); + return -1; } } - /* Finally call the driver */ - Result = ppdev->DriverFunctions.Escape( - &psurf->SurfObj, - Escape, - InSize, - SafeInData, - OutSize, - SafeOutData ); + Result = IntGdiExtEscape ( pDC, Escape, InSize, SafeInData, OutSize, SafeOutData ); -Exit: - if (hDC == NULL) - { - EngReleaseSemaphore(ppdev->hsemDevLock); - } - SURFACE_ShareUnlockSurface(psurf); - PDEVOBJ_vRelease(ppdev); + DC_UnlockDc(pDC); if ( SafeInData ) - { ExFreePoolWithTag ( SafeInData ,GDITAG_TEMP ); - } if ( SafeOutData ) { - if (Result > 0) + _SEH2_TRY + { + /* Pointers were already probed! */ + RtlCopyMemory(UnsafeOutData, + SafeOutData, + OutSize); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - _SEH2_TRY - { - /* Pointers were already probed! */ - RtlCopyMemory(UnsafeOutData, SafeOutData, OutSize); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END; - - if ( !NT_SUCCESS(Status) ) - { - SetLastNtError(Status); - Result = -1; - } + Status = _SEH2_GetExceptionCode(); } + _SEH2_END; ExFreePoolWithTag ( SafeOutData, GDITAG_TEMP ); + if ( !NT_SUCCESS(Status) ) + { + SetLastNtError(Status); + return -1; + } } return Result;