Author: jimtabor
Date: Sun Sep 2 11:59:12 2007
New Revision: 28756
URL:
http://svn.reactos.org/svn/reactos?rev=28756&view=rev
Log:
Working Dc_Attr support, tested and it worked. Will plugin the rest later.
Modified:
trunk/reactos/subsystems/win32/win32k/include/dc.h
trunk/reactos/subsystems/win32/win32k/objects/dcutil.c
Modified: trunk/reactos/subsystems/win32/win32k/include/dc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/dc.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/dc.h Sun Sep 2 11:59:12 2007
@@ -145,6 +145,7 @@
VOID FASTCALL DC_InitDC(HDC DCToInit);
HDC FASTCALL DC_FindOpenDC(PUNICODE_STRING Driver);
VOID FASTCALL DC_FreeDC(HDC DCToFree);
+VOID FASTCALL DC_FreeDcAttr(HDC);
BOOL INTERNAL_CALL DC_Cleanup(PVOID ObjectBody);
HDC FASTCALL DC_GetNextDC (PDC pDC);
VOID FASTCALL DC_SetNextDC (PDC pDC, HDC hNextDC);
@@ -154,6 +155,10 @@
BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest);
BOOL FASTCALL DCU_UpdateUserXForms(PDC, ULONG);
+BOOL FASTCALL DCU_SyncDcAttrtoUser(PDC, FLONG);
+BOOL FASTCALL DCU_SynchDcAttrtoUser(HDC, FLONG);
+BOOL FASTCALL DCU_SyncDcAttrtoW32k(PDC, FLONG);
+BOOL FASTCALL DCU_SynchDcAttrtoW32k(HDC, FLONG);
VOID FASTCALL IntGetViewportExtEx(PDC dc, LPSIZE pt);
VOID FASTCALL IntGetViewportOrgEx(PDC dc, LPPOINT pt);
Modified: trunk/reactos/subsystems/win32/win32k/objects/dcutil.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dcutil.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dcutil.c Sun Sep 2 11:59:12 2007
@@ -3,6 +3,121 @@
#define NDEBUG
#include <debug.h>
+
+static
+VOID
+CopytoUserDcAttr(PDC dc, PDC_ATTR Dc_Attr, FLONG Dirty)
+{
+
+ Dc_Attr->hpen = dc->Dc_Attr.hpen;
+ Dc_Attr->hbrush = dc->Dc_Attr.hbrush;
+ Dc_Attr->hColorSpace = dc->Dc_Attr.hColorSpace;
+ Dc_Attr->hlfntNew = dc->Dc_Attr.hlfntNew;
+
+ Dc_Attr->jROP2 = dc->Dc_Attr.jROP2;
+ Dc_Attr->jFillMode = dc->Dc_Attr.jFillMode;
+ Dc_Attr->jStretchBltMode = dc->Dc_Attr.jStretchBltMode;
+ Dc_Attr->lRelAbs = dc->Dc_Attr.lRelAbs;
+ Dc_Attr->jBkMode = dc->Dc_Attr.jBkMode;
+
+ Dc_Attr->crBackgroundClr = dc->Dc_Attr.crBackgroundClr;
+ Dc_Attr->ulBackgroundClr = dc->Dc_Attr.ulBackgroundClr;
+ Dc_Attr->crForegroundClr = dc->Dc_Attr.crForegroundClr;
+ Dc_Attr->ulForegroundClr = dc->Dc_Attr.ulForegroundClr;
+
+ Dc_Attr->ulBrushClr = dc->Dc_Attr.ulBrushClr;
+ Dc_Attr->crBrushClr = dc->Dc_Attr.crBrushClr;
+
+ Dc_Attr->ulPenClr = dc->Dc_Attr.ulPenClr;
+ Dc_Attr->crPenClr = dc->Dc_Attr.crPenClr;
+
+ Dc_Attr->ptlBrushOrigin.x = dc->Dc_Attr.ptlBrushOrigin.x;
+ Dc_Attr->ptlBrushOrigin.y = dc->Dc_Attr.ptlBrushOrigin.y;
+
+ Dc_Attr->lTextAlign = dc->Dc_Attr.lTextAlign;
+ Dc_Attr->lTextExtra = dc->Dc_Attr.lTextExtra;
+ Dc_Attr->cBreak = dc->Dc_Attr.cBreak;
+ Dc_Attr->lBreakExtra = dc->Dc_Attr.lBreakExtra;
+ Dc_Attr->iMapMode = dc->Dc_Attr.iMapMode;
+ Dc_Attr->iGraphicsMode = dc->Dc_Attr.iGraphicsMode;
+
+ Dc_Attr->ptlCurrent.x = dc->Dc_Attr.ptlCurrent.x;
+ Dc_Attr->ptlCurrent.y = dc->Dc_Attr.ptlCurrent.y;
+ Dc_Attr->ptlWindowOrg.x = dc->Dc_Attr.ptlWindowOrg.x;
+ Dc_Attr->ptlWindowOrg.y = dc->Dc_Attr.ptlWindowOrg.y;
+ Dc_Attr->szlWindowExt.cx = dc->Dc_Attr.szlWindowExt.cx;
+ Dc_Attr->szlWindowExt.cy = dc->Dc_Attr.szlWindowExt.cy;
+ Dc_Attr->ptlViewportOrg.x = dc->Dc_Attr.ptlViewportOrg.x;
+ Dc_Attr->ptlViewportOrg.y = dc->Dc_Attr.ptlViewportOrg.y;
+ Dc_Attr->szlViewportExt.cx = dc->Dc_Attr.szlViewportExt.cx;
+ Dc_Attr->szlViewportExt.cy = dc->Dc_Attr.szlViewportExt.cy;
+
+ Dc_Attr->ulDirty_ = 0; // Force to Zero!
+}
+
+static
+VOID
+CopyFromUserDcAttr(PDC dc, PDC_ATTR Dc_Attr, FLONG Dirty)
+{
+ if ( (Dirty & DIRTY_FILL) || (Dc_Attr->ulDirty_ & DIRTY_FILL))
+ {
+ dc->Dc_Attr.ulBrushClr = Dc_Attr->ulBrushClr;
+ dc->Dc_Attr.crBrushClr = Dc_Attr->crBrushClr;
+ Dc_Attr->ulDirty_ &= ~DIRTY_FILL;
+ }
+ if ( Dirty & DIRTY_LINE || (Dc_Attr->ulDirty_ & DIRTY_LINE))
+ {
+ dc->Dc_Attr.ulPenClr = Dc_Attr->ulPenClr;
+ dc->Dc_Attr.crPenClr = Dc_Attr->crPenClr;
+ Dc_Attr->ulDirty_ &= ~DIRTY_LINE;
+ }
+}
+
+static
+BOOL
+ReadWriteVMDcAttr(PDC dc, FLONG Dirty, BOOL Write)
+{
+ BOOL Ret = FALSE;
+ KeEnterCriticalRegion();
+ {
+ INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)dc->hSelf);
+ PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index];
+ HANDLE ProcessId = (HANDLE)(((ULONG_PTR)(Entry->ProcessId)) & 0x0000ffff);
+ DC_ATTR lDc_AttrData;
+
+ if(Entry->UserData)
+ {
+ NTSTATUS Status = ZwReadVirtualMemory ( ProcessId,
+ &(Entry->UserData),
+ &lDc_AttrData,
+ sizeof(DC_ATTR),
+ NULL );
+ if (Write)
+ {
+ if (NT_SUCCESS(Status)) CopytoUserDcAttr(dc, &lDc_AttrData, Dirty);
+ Ret = TRUE;
+ }
+ else
+ {
+ if (NT_SUCCESS(Status)) CopyFromUserDcAttr(dc, &lDc_AttrData, Dirty);
+ Ret = TRUE;
+ }
+ if (Write)
+ Status = ZwWriteVirtualMemory ( ProcessId,
+ &(Entry->UserData),
+ &lDc_AttrData,
+ sizeof(DC_ATTR),
+ NULL );
+ if(!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ Ret = FALSE;
+ }
+ }
+ }
+ KeLeaveCriticalRegion();
+ return Ret;
+}
BOOL
@@ -41,12 +156,103 @@
{
SetLastNtError(Status);
return FALSE;
- }
+ }
}
#endif
return TRUE;
}
+BOOL
+FASTCALL
+DCU_SyncDcAttrtoUser(PDC dc, FLONG Dirty)
+{
+ BOOL TryHarder = FALSE;
+ PDC_ATTR Dc_Attr = dc->pDc_Attr;
+ if (!Dirty) return FALSE;
+ if (!Dc_Attr) return FALSE;
+ else
+ {
+ NTSTATUS Status = STATUS_SUCCESS;
+ _SEH_TRY
+ {
+ ProbeForWrite(Dc_Attr,
+ sizeof(DC_ATTR),
+ 1);
+ CopytoUserDcAttr( dc, Dc_Attr, Dirty);
+ }
+ _SEH_HANDLE
+ {
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
+ if(!NT_SUCCESS(Status))
+ {
+ TryHarder = TRUE;
+ }
+ if (TryHarder)
+ {
+ return ReadWriteVMDcAttr( dc, Dirty, TRUE);
+ }
+ }
+ return TRUE;
+}
+
+BOOL
+FASTCALL
+DCU_SynchDcAttrtoUser(HDC hDC, FLONG Dirty)
+{
+ PDC pDC = DC_LockDc ( hDC );
+ BOOL Ret = DCU_SyncDcAttrtoUser(pDC, Dirty);
+ DC_UnlockDc( pDC );
+ return Ret;
+}
+
+BOOL
+FASTCALL
+DCU_SyncDcAttrtoW32k(PDC dc, FLONG Dirty)
+{
+ BOOL TryHarder = FALSE;
+ PDC_ATTR Dc_Attr = dc->pDc_Attr;
+ if (!Dirty) return FALSE;
+ if (!Dc_Attr) return FALSE;
+ else
+ {
+ NTSTATUS Status = STATUS_SUCCESS;
+ _SEH_TRY
+ {
+ ProbeForRead(Dc_Attr,
+ sizeof(DC_ATTR),
+ 1);
+ CopyFromUserDcAttr( dc, Dc_Attr, Dirty);
+ }
+ _SEH_HANDLE
+ {
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
+ if(!NT_SUCCESS(Status))
+ {
+ TryHarder = TRUE;
+ }
+ if (TryHarder)
+ {
+ return ReadWriteVMDcAttr( dc, Dirty, FALSE);
+ }
+ }
+ return TRUE;
+}
+
+BOOL
+FASTCALL
+DCU_SynchDcAttrtoW32k(HDC hDC, FLONG Dirty)
+{
+ PDC pDC = DC_LockDc ( hDC );
+ BOOL Ret = DCU_SyncDcAttrtoW32k(pDC, Dirty);
+ DC_UnlockDc( pDC );
+ return Ret;
+}
+
+
VOID
APIENTRY