mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 09:06:22 +00:00
- 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:
parent
d591f751c7
commit
6b4b2a47a3
5 changed files with 22 additions and 11 deletions
|
@ -6454,6 +6454,12 @@ RtlxUnicodeStringToAnsiSize(
|
||||||
#define RtlZeroBytes RtlZeroMemory
|
#define RtlZeroBytes RtlZeroMemory
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
NTKERNELAPI
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
KeAreAllApcsDisabled(
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
/* Guarded Mutex routines */
|
/* Guarded Mutex routines */
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,10 @@ ObInit(VOID)
|
||||||
/* Initialize the Default Event */
|
/* Initialize the Default Event */
|
||||||
KeInitializeEvent(&ObpDefaultObject, NotificationEvent, TRUE );
|
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 */
|
/* Setup the Object Reaper */
|
||||||
ExInitializeWorkItem(&ObpReaperWorkItem, ObpReapObject, NULL);
|
ExInitializeWorkItem(&ObpReaperWorkItem, ObpReapObject, NULL);
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,9 @@ ObpDeleteObject(IN PVOID Object,
|
||||||
/* Check if we have a delete procedure */
|
/* Check if we have a delete procedure */
|
||||||
if (ObjectType->TypeInfo.DeleteProcedure)
|
if (ObjectType->TypeInfo.DeleteProcedure)
|
||||||
{
|
{
|
||||||
|
/* Save whether we were deleted from worker thread or not */
|
||||||
|
if (!CalledFromWorkerThread) Header->Flags |= OB_FLAG_DEFER_DELETE;
|
||||||
|
|
||||||
/* Call it */
|
/* Call it */
|
||||||
ObpCalloutStart(&CalloutIrql);
|
ObpCalloutStart(&CalloutIrql);
|
||||||
ObjectType->TypeInfo.DeleteProcedure(Object);
|
ObjectType->TypeInfo.DeleteProcedure(Object);
|
||||||
|
@ -207,14 +210,13 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
ObpReapObject(IN PVOID Parameter)
|
ObpReapObject(IN PVOID Parameter)
|
||||||
{
|
{
|
||||||
POBJECT_HEADER ReapObject = (PVOID)1;
|
POBJECT_HEADER ReapObject, NextObject;
|
||||||
PVOID NextObject;
|
|
||||||
|
|
||||||
/* Start reaping */
|
/* Start reaping */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Get the reap object */
|
/* Get the reap object */
|
||||||
ReapObject = InterlockedExchangePointer(&ObpReaperList, ReapObject);
|
ReapObject = InterlockedExchangePointer(&ObpReaperList, (PVOID)1);
|
||||||
|
|
||||||
/* Start deletion loop */
|
/* Start deletion loop */
|
||||||
do
|
do
|
||||||
|
@ -227,7 +229,7 @@ ObpReapObject(IN PVOID Parameter)
|
||||||
|
|
||||||
/* Move to the next one */
|
/* Move to the next one */
|
||||||
ReapObject = NextObject;
|
ReapObject = NextObject;
|
||||||
} while ((NextObject) && (NextObject != (PVOID)1));
|
} while ((ReapObject) && (ReapObject != (PVOID)1));
|
||||||
} while ((ObpReaperList != (PVOID)1) ||
|
} while ((ObpReaperList != (PVOID)1) ||
|
||||||
(InterlockedCompareExchange((PLONG)&ObpReaperList, 0, 1) != 1));
|
(InterlockedCompareExchange((PLONG)&ObpReaperList, 0, 1) != 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include <ntoskrnl.h>
|
#include <ntoskrnl.h>
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS *********************************************************/
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
ObpDeferObjectDeletion(IN POBJECT_HEADER Header)
|
ObpDeferObjectDeletion(IN POBJECT_HEADER Header)
|
||||||
{
|
{
|
||||||
PVOID Entry, NewEntry;
|
PVOID Entry;
|
||||||
|
|
||||||
/* Loop while trying to update the list */
|
/* Loop while trying to update the list */
|
||||||
do
|
do
|
||||||
|
@ -62,11 +62,10 @@ ObpDeferObjectDeletion(IN POBJECT_HEADER Header)
|
||||||
|
|
||||||
/* Link our object to the list */
|
/* Link our object to the list */
|
||||||
Header->NextToFree = Entry;
|
Header->NextToFree = Entry;
|
||||||
NewEntry = Header;
|
|
||||||
|
|
||||||
/* Update the list */
|
/* Update the list */
|
||||||
} while (InterlockedCompareExchangePointer(&ObpReaperList,
|
} while (InterlockedCompareExchangePointer(&ObpReaperList,
|
||||||
NewEntry,
|
Header,
|
||||||
Entry) != Entry);
|
Entry) != Entry);
|
||||||
|
|
||||||
/* Queue the work item if needed */
|
/* Queue the work item if needed */
|
||||||
|
@ -306,8 +305,8 @@ ObfDereferenceObject(IN PVOID Object)
|
||||||
return Header->PointerCount;
|
return Header->PointerCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we're at PASSIVE */
|
/* Check if APCs are still active */
|
||||||
if (KeGetCurrentIrql() == PASSIVE_LEVEL)
|
if (!KeAreAllApcsDisabled())
|
||||||
{
|
{
|
||||||
/* Remove the object */
|
/* Remove the object */
|
||||||
ObpDeleteObject(Object, FALSE);
|
ObpDeleteObject(Object, FALSE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue