Author: ion Date: Mon Jan 15 23:54:40 2007 New Revision: 25471
URL: http://svn.reactos.org/svn/reactos?rev=25471&view=rev Log: - Add KeAreAllApcsDisabled to DDK. [4 bug fixes]: - Setup default GrantedAccess for system init thread/process in ObInit. - Fix a small bug in ObpReapObject. - Set object header flag is deletion was done deferred. - Simplify ObpDeferObjectDeletion. - Use KeAreAllApcsDisabled instead of only checking IRQL to determine if we should do defered deletion.
Modified: trunk/reactos/include/ddk/winddk.h trunk/reactos/ntoskrnl/ob/obinit.c trunk/reactos/ntoskrnl/ob/oblife.c trunk/reactos/ntoskrnl/ob/obname.c trunk/reactos/ntoskrnl/ob/obref.c
Modified: trunk/reactos/include/ddk/winddk.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/winddk.h?rev=25... ============================================================================== --- trunk/reactos/include/ddk/winddk.h (original) +++ trunk/reactos/include/ddk/winddk.h Mon Jan 15 23:54:40 2007 @@ -6454,6 +6454,12 @@ #define RtlZeroBytes RtlZeroMemory #endif
+NTKERNELAPI +BOOLEAN +NTAPI +KeAreAllApcsDisabled( + VOID +);
/* Guarded Mutex routines */
Modified: trunk/reactos/ntoskrnl/ob/obinit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obinit.c?rev=25... ============================================================================== --- trunk/reactos/ntoskrnl/ob/obinit.c (original) +++ trunk/reactos/ntoskrnl/ob/obinit.c Mon Jan 15 23:54:40 2007 @@ -172,6 +172,10 @@
/* 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);
Modified: trunk/reactos/ntoskrnl/ob/oblife.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/oblife.c?rev=25... ============================================================================== --- trunk/reactos/ntoskrnl/ob/oblife.c (original) +++ trunk/reactos/ntoskrnl/ob/oblife.c Mon Jan 15 23:54:40 2007 @@ -193,6 +193,9 @@ /* 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 @@ 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 @@
/* 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)); }
Modified: trunk/reactos/ntoskrnl/ob/obname.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obname.c?rev=25... ============================================================================== --- trunk/reactos/ntoskrnl/ob/obname.c (original) +++ trunk/reactos/ntoskrnl/ob/obname.c Mon Jan 15 23:54:40 2007 @@ -55,7 +55,7 @@ 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");
Modified: trunk/reactos/ntoskrnl/ob/obref.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obref.c?rev=254... ============================================================================== --- trunk/reactos/ntoskrnl/ob/obref.c (original) +++ trunk/reactos/ntoskrnl/ob/obref.c Mon Jan 15 23:54:40 2007 @@ -13,7 +13,7 @@
#include <ntoskrnl.h> #define NDEBUG -#include <internal/debug.h> +#include <debug.h>
/* PRIVATE FUNCTIONS *********************************************************/
@@ -52,7 +52,7 @@ NTAPI ObpDeferObjectDeletion(IN POBJECT_HEADER Header) { - PVOID Entry, NewEntry; + PVOID Entry;
/* Loop while trying to update the list */ do @@ -62,11 +62,10 @@
/* 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 @@ 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);