- 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.

svn path=/trunk/; revision=25471
This commit is contained in:
Alex Ionescu 2007-01-15 20:54:40 +00:00
parent d591f751c7
commit 6b4b2a47a3
5 changed files with 22 additions and 11 deletions

View file

@ -6454,6 +6454,12 @@ RtlxUnicodeStringToAnsiSize(
#define RtlZeroBytes RtlZeroMemory
#endif
NTKERNELAPI
BOOLEAN
NTAPI
KeAreAllApcsDisabled(
VOID
);
/* Guarded Mutex routines */

View file

@ -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);

View file

@ -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));
}

View file

@ -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");

View file

@ -13,7 +13,7 @@
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#include <debug.h>
/* 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);