diff --git a/reactos/subsystems/win32/win32k/include/gdiobj.h b/reactos/subsystems/win32/win32k/include/gdiobj.h index 901b441ee8b..7d23e4d8e61 100644 --- a/reactos/subsystems/win32/win32k/include/gdiobj.h +++ b/reactos/subsystems/win32/win32k/include/gdiobj.h @@ -94,5 +94,6 @@ PVOID INTERNAL_CALL GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCES #define GDIOBJFLAG_IGNORELOCK (0x2) BOOL FASTCALL NtGdiDeleteObject(HGDIOBJ hObject); +BOOL FASTCALL IsObjectDead(HGDIOBJ); #endif diff --git a/reactos/subsystems/win32/win32k/ntuser/windc.c b/reactos/subsystems/win32/win32k/ntuser/windc.c index eafa419f4a0..507d797e794 100644 --- a/reactos/subsystems/win32/win32k/ntuser/windc.c +++ b/reactos/subsystems/win32/win32k/ntuser/windc.c @@ -703,14 +703,9 @@ DceFreeDCE(PDCE pdce, BOOLEAN Force) if(Force && !GDIOBJ_OwnedByCurrentProcess(GdiHandleTable, pdce->hDC)) { DPRINT1("Change ownership for DCE!\n"); - INT Index = GDI_HANDLE_GET_INDEX(pdce->hDC); - PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index]; - // Must take control of handles that are not in the process of going away. - if ((Entry->Type & ~GDI_ENTRY_REUSE_MASK) != 0 && Entry->KernelData != NULL) - { + if(!IsObjectDead((HGDIOBJ) pdce->hDC)) DC_SetOwnership( pdce->hDC, PsGetCurrentProcess()); - } else { DPRINT1("Attempted to change ownership of an DCEhDC 0x%x currently being destroyed!!!\n",pdce->hDC); diff --git a/reactos/subsystems/win32/win32k/objects/dc.c b/reactos/subsystems/win32/win32k/objects/dc.c index 0ad9b63c8d4..394be3828bf 100644 --- a/reactos/subsystems/win32/win32k/objects/dc.c +++ b/reactos/subsystems/win32/win32k/objects/dc.c @@ -2433,9 +2433,7 @@ VOID FASTCALL DC_FreeDC(HDC DCToFree) { DC_FreeDcAttr(DCToFree); - INT Index = GDI_HANDLE_GET_INDEX(DCToFree); - PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index]; - if ((Entry->Type & ~GDI_ENTRY_REUSE_MASK) != 0 && Entry->KernelData != NULL) + if(!IsObjectDead( DCToFree )) { if (!GDIOBJ_FreeObj(GdiHandleTable, DCToFree, GDI_OBJECT_TYPE_DC)) { diff --git a/reactos/subsystems/win32/win32k/objects/gdiobj.c b/reactos/subsystems/win32/win32k/objects/gdiobj.c index 3476581d6ba..784dd1398e4 100644 --- a/reactos/subsystems/win32/win32k/objects/gdiobj.c +++ b/reactos/subsystems/win32/win32k/objects/gdiobj.c @@ -33,7 +33,10 @@ NTAPI KeRosDumpStackFrames( PULONG Frame, ULONG FrameCount -); +) +{ + return; +} #define GDI_ENTRY_TO_INDEX(ht, e) \ (((ULONG_PTR)(e) - (ULONG_PTR)&((ht)->Entries[0])) / sizeof(GDI_TABLE_ENTRY)) @@ -328,7 +331,6 @@ LockErrorDebugOutput(HGDIOBJ hObj, PGDI_TABLE_ENTRY Entry, LPSTR Function) Function, hObj, Entry->Type); } KeRosDumpStackFrames(NULL, 20); - } /*! @@ -658,6 +660,23 @@ LockHandle: return FALSE; } +BOOL +FASTCALL +IsObjectDead(HGDIOBJ hObject) +{ + INT Index = GDI_HANDLE_GET_INDEX(hObject); + PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index]; + // We check to see if the objects are knocking on deaths door. + if ((Entry->Type & ~GDI_ENTRY_REUSE_MASK) != 0 && Entry->KernelData != NULL) + return FALSE; + else + { + DPRINT1("Object 0x%x currently being destroyed!!!\n",hObject); + return TRUE; // return true and move on. + } +} + + /*! * Delete GDI object * \param hObject object handle @@ -668,13 +687,10 @@ FASTCALL NtGdiDeleteObject(HGDIOBJ hObject) { DPRINT("NtGdiDeleteObject handle 0x%08x\n", hObject); - INT Index = GDI_HANDLE_GET_INDEX(hObject); - PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index]; - // We check to see if the objects are knocking on deaths door. - if ((Entry->Type & ~GDI_ENTRY_REUSE_MASK) != 0 && Entry->KernelData != NULL) + if(!IsObjectDead(hObject)) { return NULL != hObject - ? GDIOBJ_FreeObj(GdiHandleTable, hObject, GDI_OBJECT_TYPE_DONTCARE) : FALSE; + ? GDIOBJ_FreeObj(GdiHandleTable, hObject, GDI_OBJECT_TYPE_DONTCARE) : FALSE; } else {