diff --git a/reactos/include/ddk/winddk.h b/reactos/include/ddk/winddk.h index 2b0bc988300..8cb5fe35bf8 100644 --- a/reactos/include/ddk/winddk.h +++ b/reactos/include/ddk/winddk.h @@ -6454,6 +6454,12 @@ RtlxUnicodeStringToAnsiSize( #define RtlZeroBytes RtlZeroMemory #endif +NTKERNELAPI +BOOLEAN +NTAPI +KeAreAllApcsDisabled( + VOID +); /* Guarded Mutex routines */ diff --git a/reactos/ntoskrnl/ob/obinit.c b/reactos/ntoskrnl/ob/obinit.c index 5f023dda3bf..d3c7042d8e2 100644 --- a/reactos/ntoskrnl/ob/obinit.c +++ b/reactos/ntoskrnl/ob/obinit.c @@ -173,6 +173,10 @@ ObInit(VOID) /* Initialize the Default Event */ KeInitializeEvent(&ObpDefaultObject, NotificationEvent, TRUE ); + /* Setup default access for the system process */ + PsGetCurrentProcess()->GrantedAccess = PROCESS_ALL_ACCESS; + PsGetCurrentThread()->GrantedAccess = THREAD_ALL_ACCESS; + /* Setup the Object Reaper */ ExInitializeWorkItem(&ObpReaperWorkItem, ObpReapObject, NULL); diff --git a/reactos/ntoskrnl/ob/oblife.c b/reactos/ntoskrnl/ob/oblife.c index b791acb7833..e400a672acd 100644 --- a/reactos/ntoskrnl/ob/oblife.c +++ b/reactos/ntoskrnl/ob/oblife.c @@ -193,6 +193,9 @@ ObpDeleteObject(IN PVOID Object, /* Check if we have a delete procedure */ if (ObjectType->TypeInfo.DeleteProcedure) { + /* Save whether we were deleted from worker thread or not */ + if (!CalledFromWorkerThread) Header->Flags |= OB_FLAG_DEFER_DELETE; + /* Call it */ ObpCalloutStart(&CalloutIrql); ObjectType->TypeInfo.DeleteProcedure(Object); @@ -207,14 +210,13 @@ VOID NTAPI ObpReapObject(IN PVOID Parameter) { - POBJECT_HEADER ReapObject = (PVOID)1; - PVOID NextObject; + POBJECT_HEADER ReapObject, NextObject; /* Start reaping */ do { /* Get the reap object */ - ReapObject = InterlockedExchangePointer(&ObpReaperList, ReapObject); + ReapObject = InterlockedExchangePointer(&ObpReaperList, (PVOID)1); /* Start deletion loop */ do @@ -227,7 +229,7 @@ ObpReapObject(IN PVOID Parameter) /* Move to the next one */ ReapObject = NextObject; - } while ((NextObject) && (NextObject != (PVOID)1)); + } while ((ReapObject) && (ReapObject != (PVOID)1)); } while ((ObpReaperList != (PVOID)1) || (InterlockedCompareExchange((PLONG)&ObpReaperList, 0, 1) != 1)); } diff --git a/reactos/ntoskrnl/ob/obname.c b/reactos/ntoskrnl/ob/obname.c index 345b6df21d0..143a1bcec70 100644 --- a/reactos/ntoskrnl/ob/obname.c +++ b/reactos/ntoskrnl/ob/obname.c @@ -55,7 +55,7 @@ ObpCreateDosDevicesDirectory(VOID) SYMBOLIC_LINK_ALL_ACCESS, &ObjectAttributes, &Name); - if (NT_SUCCESS(Status)) NtClose(SymHandle); + if (NT_SUCCESS(Status)) NtClose(SymHandle); /* Link \??\Global to \?? */ RtlInitUnicodeString(&LinkName, L"Global"); diff --git a/reactos/ntoskrnl/ob/obref.c b/reactos/ntoskrnl/ob/obref.c index 519f6798aa2..22b6285c423 100644 --- a/reactos/ntoskrnl/ob/obref.c +++ b/reactos/ntoskrnl/ob/obref.c @@ -13,7 +13,7 @@ #include #define NDEBUG -#include +#include /* PRIVATE FUNCTIONS *********************************************************/ @@ -52,7 +52,7 @@ VOID NTAPI ObpDeferObjectDeletion(IN POBJECT_HEADER Header) { - PVOID Entry, NewEntry; + PVOID Entry; /* Loop while trying to update the list */ do @@ -62,11 +62,10 @@ ObpDeferObjectDeletion(IN POBJECT_HEADER Header) /* Link our object to the list */ Header->NextToFree = Entry; - NewEntry = Header; /* Update the list */ } while (InterlockedCompareExchangePointer(&ObpReaperList, - NewEntry, + Header, Entry) != Entry); /* Queue the work item if needed */ @@ -306,8 +305,8 @@ ObfDereferenceObject(IN PVOID Object) return Header->PointerCount; } - /* Check if we're at PASSIVE */ - if (KeGetCurrentIrql() == PASSIVE_LEVEL) + /* Check if APCs are still active */ + if (!KeAreAllApcsDisabled()) { /* Remove the object */ ObpDeleteObject(Object, FALSE);