Author: jimtabor
Date: Sat Oct 13 08:15:37 2007
New Revision: 29546
URL:
http://svn.reactos.org/svn/reactos?rev=29546&view=rev
Log:
Dc_Attr with DCE:
- Fixed problem with dcattr read and write access in user mode.
- Dcattr data only flows from Kernel to User ATM.
- Cleaned up code.
- Enable GetDCObject for testing.
- Tested with Qemu both Linux and XP, and real hardware.
Modified:
trunk/reactos/dll/win32/gdi32/objects/dc.c
trunk/reactos/subsystems/win32/win32k/include/dc.h
trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
trunk/reactos/subsystems/win32/win32k/objects/dc.c
Modified: trunk/reactos/dll/win32/gdi32/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/dc…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/dc.c (original)
+++ trunk/reactos/dll/win32/gdi32/objects/dc.c Sat Oct 13 08:15:37 2007
@@ -320,7 +320,6 @@
STDCALL
GetDCObject( HDC hDC, INT iType)
{
-#if 0
if((iType == GDI_OBJECT_TYPE_BRUSH) ||
(iType == GDI_OBJECT_TYPE_EXTPEN)||
(iType == GDI_OBJECT_TYPE_PEN) ||
@@ -348,7 +347,6 @@
}
return hGO;
}
-#endif
return NtGdiGetDCObject( hDC, iType );
}
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 Sat Oct 13 08:15:37 2007
@@ -150,8 +150,8 @@
VOID FASTCALL DC_InitDC(HDC DCToInit);
HDC FASTCALL DC_FindOpenDC(PUNICODE_STRING Driver);
VOID FASTCALL DC_FreeDC(HDC);
-VOID FASTCALL DC_AllocateDcAttr(HDC, PEPROCESS);
-VOID FASTCALL DC_FreeDcAttr(HDC, PEPROCESS);
+VOID FASTCALL DC_AllocateDcAttr(HDC);
+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);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/windc.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/windc.c Sat Oct 13 08:15:37 2007
@@ -153,6 +153,8 @@
}
else
{
+ DPRINT("FREE DCATTR!!!! NOT DCE_WINDOW_DC!!!!! hDC-> %x\n",
pDce->hDC);
+ DC_FreeDcAttr(pDce->hDC); // Free the dcattr!
DC_SetOwnership(pDce->hDC, NULL); // This hDC is inaccessible!
}
@@ -267,6 +269,10 @@
dce->DCXFlags |= DCX_DCEEMPTY;
}
}
+ DPRINT("Exit!!!!! DCX_CACHE!!!!!! hDC-> %x \n", dce->hDC);
+ DC_FreeDcAttr(dce->hDC); // Free the dcattr.
+ DC_SetOwnership(dce->hDC, NULL); // Set hDC inaccessible mode.
+ dce->pProcess = NULL; // Reset ownership.
}
return 1;
}
@@ -543,6 +549,15 @@
DceUpdateVisRgn(Dce, Window, Flags);
}
+ if (Dce->DCXFlags & DCX_CACHE)
+ {
+ DPRINT("ENTER!!!!!! DCX_CACHE!!!!!! hDC-> %x\n", Dce->hDC);
+ // Need to set ownership so Sync dcattr will work.
+ DC_SetOwnership( Dce->hDC, PsGetCurrentProcess());
+ DC_AllocateDcAttr( Dce->hDC ); // Allocate new dcattr
+ DCU_SynchDcAttrtoUser( Dce->hDC, -1); // Copy data from dc to dcattr
+ Dce->pProcess = PsGetCurrentProcess(); // Set the temp owning process
+ }
return(Dce->hDC);
}
Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dc.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dc.c Sat Oct 13 08:15:37 2007
@@ -2399,7 +2399,7 @@
return NULL;
}
- DC_AllocateDcAttr(hDC, NULL);
+ DC_AllocateDcAttr(hDC);
NewDC = DC_LockDc(hDC);
/* FIXME - Handle NewDC == NULL! */
@@ -2482,14 +2482,12 @@
VOID
FASTCALL
-DC_AllocateDcAttr(HDC hDC, PEPROCESS Owner)
-{
-//#if 0
+DC_AllocateDcAttr(HDC hDC)
+{
PVOID NewMem = NULL;
HANDLE Pid = NtCurrentProcess();
ULONG MemSize = sizeof(DC_ATTR); //PAGE_SIZE it will allocate that size
- if(Owner) Pid = PsGetProcessId(Owner);
NTSTATUS Status = ZwAllocateVirtualMemory(Pid,
&NewMem,
0,
@@ -2519,19 +2517,17 @@
pDC->pDc_Attr = NewMem; // Store pointer
}
DC_UnlockDc(pDC);
-//#endif
}
VOID
FASTCALL
-DC_FreeDcAttr(HDC DCToFree, PEPROCESS Owner)
+DC_FreeDcAttr(HDC DCToFree )
{
HANDLE Pid = NtCurrentProcess();
PDC pDC = DC_LockDc(DCToFree);
if (pDC->pDc_Attr == &pDC->Dc_Attr) return; // Internal DC object!
pDC->pDc_Attr = NULL;
DC_UnlockDc(pDC);
- if(Owner) Pid = PsGetProcessId(Owner);
KeEnterCriticalRegion();
{
@@ -2557,9 +2553,8 @@
VOID FASTCALL
DC_FreeDC(HDC DCToFree)
{
-//#if 0
- DC_FreeDcAttr(DCToFree, NULL);
-//#endif
+ DC_FreeDcAttr(DCToFree);
+
if (!GDIOBJ_FreeObj(GdiHandleTable, DCToFree, GDI_OBJECT_TYPE_DC))
{
DPRINT("DC_FreeDC failed\n");