mirror of
https://github.com/reactos/reactos.git
synced 2025-04-15 01:47:30 +00:00
- Use the proper HANDLE_TABLE and HANDLE_TABLE_ENTRY structures.
svn path=/trunk/; revision=21942
This commit is contained in:
parent
13cc9dd150
commit
907b271b84
9 changed files with 168 additions and 117 deletions
|
@ -467,6 +467,24 @@ typedef struct _EPROFILE
|
|||
//
|
||||
// Handle Table Structures
|
||||
//
|
||||
typedef struct _HANDLE_TRACE_DB_ENTRY
|
||||
{
|
||||
CLIENT_ID ClientId;
|
||||
HANDLE Handle;
|
||||
ULONG Type;
|
||||
PVOID StackTrace[16];
|
||||
} HANDLE_TRACE_DB_ENTRY, *PHANDLE_TRACE_DB_ENTRY;
|
||||
|
||||
typedef struct _HANDLE_TRACE_DEBUG_INFO
|
||||
{
|
||||
LONG RefCount;
|
||||
ULONG TableSize;
|
||||
ULONG BitMaskFlags;
|
||||
FAST_MUTEX CloseCompatcionLock;
|
||||
ULONG CurrentStackIndex;
|
||||
HANDLE_TRACE_DB_ENTRY TraceDb[1];
|
||||
} HANDLE_TRACE_DEBUG_INFO, *PHANDLE_TRACE_DEBUG_INFO;
|
||||
|
||||
typedef struct _HANDLE_TABLE_ENTRY_INFO
|
||||
{
|
||||
ULONG AuditMask;
|
||||
|
@ -480,27 +498,60 @@ typedef struct _HANDLE_TABLE_ENTRY
|
|||
ULONG_PTR ObAttributes;
|
||||
PHANDLE_TABLE_ENTRY_INFO InfoTable;
|
||||
ULONG_PTR Value;
|
||||
} u1;
|
||||
};
|
||||
union
|
||||
{
|
||||
ULONG GrantedAccess;
|
||||
USHORT GrantedAccessIndex;
|
||||
struct
|
||||
{
|
||||
USHORT GrantedAccessIndex;
|
||||
USHORT CreatorBackTraceIndex;
|
||||
};
|
||||
LONG NextFreeTableEntry;
|
||||
} u2;
|
||||
};
|
||||
} HANDLE_TABLE_ENTRY, *PHANDLE_TABLE_ENTRY;
|
||||
|
||||
typedef struct _HANDLE_TABLE
|
||||
{
|
||||
ULONG Flags;
|
||||
LONG HandleCount;
|
||||
#if (NTDDI_VERSION >= NTDDI_WINXP)
|
||||
ULONG TableCode;
|
||||
#else
|
||||
PHANDLE_TABLE_ENTRY **Table;
|
||||
#endif
|
||||
PEPROCESS QuotaProcess;
|
||||
HANDLE UniqueProcessId;
|
||||
LONG FirstFreeTableEntry;
|
||||
LONG NextIndexNeedingPool;
|
||||
ERESOURCE HandleTableLock;
|
||||
PVOID UniqueProcessId;
|
||||
#if (NTDDI_VERSION >= NTDDI_WINXP)
|
||||
EX_PUSH_LOCK HandleLock;
|
||||
LIST_ENTRY HandleTableList;
|
||||
EX_PUSH_LOCK HandleContentionEvent;
|
||||
#else
|
||||
ERESOURCE HandleLock;
|
||||
LIST_ENTRY HandleTableList;
|
||||
KEVENT HandleContentionEvent;
|
||||
#endif
|
||||
PHANDLE_TRACE_DEBUG_INFO DebugInfo;
|
||||
LONG ExtraInfoPages;
|
||||
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
|
||||
union
|
||||
{
|
||||
ULONG Flags;
|
||||
UCHAR StrictFIFO:1;
|
||||
};
|
||||
LONG FirstFreeHandle;
|
||||
PHANDLE_TABLE_ENTRY LastFreeHandleEntry;
|
||||
LONG HandleCount;
|
||||
ULONG NextHandleNeedingPool;
|
||||
#else
|
||||
ULONG FirstFree;
|
||||
ULONG LastFree;
|
||||
ULONG NextHandleNeedingPool;
|
||||
LONG HandleCount;
|
||||
union
|
||||
{
|
||||
ULONG Flags;
|
||||
UCHAR StrictFIFO:1;
|
||||
};
|
||||
#endif
|
||||
} HANDLE_TABLE, *PHANDLE_TABLE;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,14 +33,14 @@ static LARGE_INTEGER ExpHandleShortWait;
|
|||
#define ExReleaseHandleTableListLock() \
|
||||
ExReleaseFastMutexUnsafe(&ExpHandleTableListLock)
|
||||
|
||||
#define ExAcquireHandleTableLockExclusive(HandleTable) \
|
||||
ExAcquireResourceExclusiveLite(&(HandleTable)->HandleTableLock, TRUE)
|
||||
#define ExAcquireHandleLockExclusive(HandleTable) \
|
||||
ExAcquireResourceExclusiveLite(&(HandleTable)->HandleLock, TRUE)
|
||||
|
||||
#define ExAcquireHandleTableLockShared(HandleTable) \
|
||||
ExAcquireResourceSharedLite(&(HandleTable)->HandleTableLock, TRUE)
|
||||
#define ExAcquireHandleLockShared(HandleTable) \
|
||||
ExAcquireResourceSharedLite(&(HandleTable)->HandleLock, TRUE)
|
||||
|
||||
#define ExReleaseHandleTableLock(HandleTable) \
|
||||
ExReleaseResourceLite(&(HandleTable)->HandleTableLock)
|
||||
#define ExReleaseHandleLock(HandleTable) \
|
||||
ExReleaseResourceLite(&(HandleTable)->HandleLock)
|
||||
|
||||
/*
|
||||
5 bits: reserved
|
||||
|
@ -123,11 +123,11 @@ ExCreateHandleTable(IN PEPROCESS QuotaProcess OPTIONAL)
|
|||
HandleTable->HandleCount = 0;
|
||||
HandleTable->Table = (PHANDLE_TABLE_ENTRY**)(HandleTable + 1);
|
||||
HandleTable->QuotaProcess = QuotaProcess;
|
||||
HandleTable->FirstFreeTableEntry = -1; /* no entries freed so far */
|
||||
HandleTable->NextIndexNeedingPool = 0; /* no entries freed so far, so we have to allocate already for the first handle */
|
||||
HandleTable->FirstFree = -1; /* no entries freed so far */
|
||||
HandleTable->NextHandleNeedingPool = 0; /* no entries freed so far, so we have to allocate already for the first handle */
|
||||
HandleTable->UniqueProcessId = (QuotaProcess ? QuotaProcess->UniqueProcessId : NULL);
|
||||
|
||||
ExInitializeResource(&HandleTable->HandleTableLock);
|
||||
ExInitializeResource(&HandleTable->HandleLock);
|
||||
|
||||
KeInitializeEvent(&HandleTable->HandleContentionEvent,
|
||||
NotificationEvent,
|
||||
|
@ -176,7 +176,7 @@ ExSweepHandleTable(IN PHANDLE_TABLE HandleTable,
|
|||
KeEnterCriticalRegion();
|
||||
|
||||
/* ensure there's no other operations going by acquiring an exclusive lock */
|
||||
ExAcquireHandleTableLockExclusive(HandleTable);
|
||||
ExAcquireHandleLockExclusive(HandleTable);
|
||||
|
||||
ASSERT(!(HandleTable->Flags & EX_HANDLE_TABLE_CLOSING));
|
||||
|
||||
|
@ -206,10 +206,10 @@ ExSweepHandleTable(IN PHANDLE_TABLE HandleTable,
|
|||
curee != laste;
|
||||
curee++)
|
||||
{
|
||||
if(curee->u1.Object != NULL && SweepHandleCallback != NULL)
|
||||
if(curee->Object != NULL && SweepHandleCallback != NULL)
|
||||
{
|
||||
curee->u1.ObAttributes |= EX_HANDLE_ENTRY_LOCKED;
|
||||
SweepHandleCallback(HandleTable, curee->u1.Object, curee->u2.GrantedAccess, Context);
|
||||
curee->ObAttributes |= EX_HANDLE_ENTRY_LOCKED;
|
||||
SweepHandleCallback(HandleTable, curee->Object, curee->GrantedAccess, Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ ExSweepHandleTable(IN PHANDLE_TABLE HandleTable,
|
|||
}
|
||||
}
|
||||
|
||||
ExReleaseHandleTableLock(HandleTable);
|
||||
ExReleaseHandleLock(HandleTable);
|
||||
|
||||
KeLeaveCriticalRegion();
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable)
|
|||
KeLeaveCriticalRegion();
|
||||
|
||||
/* free the handle table */
|
||||
ExDeleteResource(&HandleTable->HandleTableLock);
|
||||
ExDeleteResource(&HandleTable->HandleLock);
|
||||
ExFreePool(HandleTable);
|
||||
|
||||
if(QuotaProcess != NULL)
|
||||
|
@ -311,7 +311,7 @@ ExDupHandleTable(IN PEPROCESS QuotaProcess OPTIONAL,
|
|||
tli = mli = eli = 0;
|
||||
|
||||
/* make sure the other handle table isn't being changed during the duplication */
|
||||
ExAcquireHandleTableLockShared(SourceHandleTable);
|
||||
ExAcquireHandleLockShared(SourceHandleTable);
|
||||
|
||||
/* allocate enough tables */
|
||||
etlp = SourceHandleTable->Table + N_TOPLEVEL_POINTERS;
|
||||
|
@ -372,7 +372,7 @@ ExDupHandleTable(IN PEPROCESS QuotaProcess OPTIONAL,
|
|||
freehandletable:
|
||||
DPRINT1("Failed to duplicate handle table 0x%p\n", SourceHandleTable);
|
||||
|
||||
ExReleaseHandleTableLock(SourceHandleTable);
|
||||
ExReleaseHandleLock(SourceHandleTable);
|
||||
|
||||
ExDestroyHandleTable(HandleTable);
|
||||
/* allocate an empty handle table */
|
||||
|
@ -383,8 +383,8 @@ freehandletable:
|
|||
|
||||
/* duplicate the handles */
|
||||
HandleTable->HandleCount = SourceHandleTable->HandleCount;
|
||||
HandleTable->FirstFreeTableEntry = SourceHandleTable->FirstFreeTableEntry;
|
||||
HandleTable->NextIndexNeedingPool = SourceHandleTable->NextIndexNeedingPool;
|
||||
HandleTable->FirstFree = SourceHandleTable->FirstFree;
|
||||
HandleTable->NextHandleNeedingPool = SourceHandleTable->NextHandleNeedingPool;
|
||||
|
||||
/* make sure all tables are zeroed */
|
||||
KeMemoryBarrier();
|
||||
|
@ -414,7 +414,7 @@ freehandletable:
|
|||
srcstbl++, stbl++, eli++)
|
||||
{
|
||||
/* try to duplicate the source handle */
|
||||
if(srcstbl->u1.Object != NULL &&
|
||||
if(srcstbl->Object != NULL &&
|
||||
ExLockHandleTableEntry(SourceHandleTable,
|
||||
srcstbl))
|
||||
{
|
||||
|
@ -426,15 +426,15 @@ freehandletable:
|
|||
{
|
||||
/* free the entry and chain it into the free list */
|
||||
HandleTable->HandleCount--;
|
||||
stbl->u1.Object = NULL;
|
||||
stbl->u2.NextFreeTableEntry = HandleTable->FirstFreeTableEntry;
|
||||
HandleTable->FirstFreeTableEntry = BUILD_HANDLE(tli, mli, eli);
|
||||
stbl->Object = NULL;
|
||||
stbl->NextFreeTableEntry = HandleTable->FirstFree;
|
||||
HandleTable->FirstFree = BUILD_HANDLE(tli, mli, eli);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* duplicate the handle and unlock it */
|
||||
stbl->u2.GrantedAccess = srcstbl->u2.GrantedAccess;
|
||||
stbl->u1.ObAttributes = srcstbl->u1.ObAttributes & ~EX_HANDLE_ENTRY_LOCKED;
|
||||
stbl->GrantedAccess = srcstbl->GrantedAccess;
|
||||
stbl->ObAttributes = srcstbl->ObAttributes & ~EX_HANDLE_ENTRY_LOCKED;
|
||||
}
|
||||
ExUnlockHandleTableEntry(SourceHandleTable,
|
||||
srcstbl);
|
||||
|
@ -452,7 +452,7 @@ freehandletable:
|
|||
}
|
||||
|
||||
/* release the source handle table */
|
||||
ExReleaseHandleTableLock(SourceHandleTable);
|
||||
ExReleaseHandleLock(SourceHandleTable);
|
||||
}
|
||||
|
||||
return HandleTable;
|
||||
|
@ -476,12 +476,12 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
{
|
||||
ULONG tli, mli, eli;
|
||||
|
||||
if(HandleTable->FirstFreeTableEntry != -1)
|
||||
if(HandleTable->FirstFree != -1)
|
||||
{
|
||||
/* there's a free handle entry we can just grab and use */
|
||||
tli = TLI_FROM_HANDLE(HandleTable->FirstFreeTableEntry);
|
||||
mli = MLI_FROM_HANDLE(HandleTable->FirstFreeTableEntry);
|
||||
eli = ELI_FROM_HANDLE(HandleTable->FirstFreeTableEntry);
|
||||
tli = TLI_FROM_HANDLE(HandleTable->FirstFree);
|
||||
mli = MLI_FROM_HANDLE(HandleTable->FirstFree);
|
||||
eli = ELI_FROM_HANDLE(HandleTable->FirstFree);
|
||||
|
||||
/* the pointer should be valid in any way!!! */
|
||||
ASSERT(HandleTable->Table[tli]);
|
||||
|
@ -489,12 +489,12 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
|
||||
Entry = &HandleTable->Table[tli][mli][eli];
|
||||
|
||||
*Handle = EX_HANDLE_TO_HANDLE(HandleTable->FirstFreeTableEntry);
|
||||
*Handle = EX_HANDLE_TO_HANDLE(HandleTable->FirstFree);
|
||||
|
||||
/* save the index to the next free handle (if available) */
|
||||
HandleTable->FirstFreeTableEntry = Entry->u2.NextFreeTableEntry;
|
||||
Entry->u2.NextFreeTableEntry = 0;
|
||||
Entry->u1.Object = NULL;
|
||||
HandleTable->FirstFree = Entry->NextFreeTableEntry;
|
||||
Entry->NextFreeTableEntry = 0;
|
||||
Entry->Object = NULL;
|
||||
|
||||
HandleTable->HandleCount++;
|
||||
}
|
||||
|
@ -505,18 +505,18 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
ULONG i;
|
||||
BOOLEAN AllocatedMtbl;
|
||||
|
||||
ASSERT(HandleTable->NextIndexNeedingPool <= N_MAX_HANDLE);
|
||||
ASSERT(HandleTable->NextHandleNeedingPool <= N_MAX_HANDLE);
|
||||
|
||||
/* the index of the next table to be allocated was saved in
|
||||
NextIndexNeedingPool the last time a handle entry was allocated and
|
||||
NextHandleNeedingPool the last time a handle entry was allocated and
|
||||
the subhandle entry list was full. the subhandle entry index of
|
||||
NextIndexNeedingPool should be 0 here! */
|
||||
tli = TLI_FROM_HANDLE(HandleTable->NextIndexNeedingPool);
|
||||
mli = MLI_FROM_HANDLE(HandleTable->NextIndexNeedingPool);
|
||||
DPRINT("HandleTable->NextIndexNeedingPool: 0x%x\n", HandleTable->NextIndexNeedingPool);
|
||||
DPRINT("tli: 0x%x mli: 0x%x eli: 0x%x\n", tli, mli, ELI_FROM_HANDLE(HandleTable->NextIndexNeedingPool));
|
||||
NextHandleNeedingPool should be 0 here! */
|
||||
tli = TLI_FROM_HANDLE(HandleTable->NextHandleNeedingPool);
|
||||
mli = MLI_FROM_HANDLE(HandleTable->NextHandleNeedingPool);
|
||||
DPRINT("HandleTable->NextHandleNeedingPool: 0x%x\n", HandleTable->NextHandleNeedingPool);
|
||||
DPRINT("tli: 0x%x mli: 0x%x eli: 0x%x\n", tli, mli, ELI_FROM_HANDLE(HandleTable->NextHandleNeedingPool));
|
||||
|
||||
ASSERT(ELI_FROM_HANDLE(HandleTable->NextIndexNeedingPool) == 0);
|
||||
ASSERT(ELI_FROM_HANDLE(HandleTable->NextHandleNeedingPool) == 0);
|
||||
|
||||
DPRINT("HandleTable->Table[%d] == 0x%p\n", tli, HandleTable->Table[tli]);
|
||||
|
||||
|
@ -595,25 +595,25 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
|
||||
/* let's just use the very first entry */
|
||||
Entry = ntbl;
|
||||
Entry->u1.ObAttributes = EX_HANDLE_ENTRY_LOCKED;
|
||||
Entry->u2.NextFreeTableEntry = 0;
|
||||
Entry->ObAttributes = EX_HANDLE_ENTRY_LOCKED;
|
||||
Entry->NextFreeTableEntry = 0;
|
||||
|
||||
*Handle = EX_HANDLE_TO_HANDLE(HandleTable->NextIndexNeedingPool);
|
||||
*Handle = EX_HANDLE_TO_HANDLE(HandleTable->NextHandleNeedingPool);
|
||||
|
||||
HandleTable->HandleCount++;
|
||||
|
||||
/* set the FirstFreeTableEntry member to the second entry and chain the
|
||||
/* set the FirstFree member to the second entry and chain the
|
||||
free entries */
|
||||
HandleTable->FirstFreeTableEntry = HandleTable->NextIndexNeedingPool + 1;
|
||||
for(cure = Entry + 1, laste = Entry + N_SUBHANDLE_ENTRIES, i = HandleTable->FirstFreeTableEntry + 1;
|
||||
HandleTable->FirstFree = HandleTable->NextHandleNeedingPool + 1;
|
||||
for(cure = Entry + 1, laste = Entry + N_SUBHANDLE_ENTRIES, i = HandleTable->FirstFree + 1;
|
||||
cure != laste;
|
||||
cure++, i++)
|
||||
{
|
||||
cure->u1.Object = NULL;
|
||||
cure->u2.NextFreeTableEntry = i;
|
||||
cure->Object = NULL;
|
||||
cure->NextFreeTableEntry = i;
|
||||
}
|
||||
/* truncate the free entry list */
|
||||
(cure - 1)->u2.NextFreeTableEntry = -1;
|
||||
(cure - 1)->NextFreeTableEntry = -1;
|
||||
|
||||
/* save the pointers to the allocated list(s) */
|
||||
(void)InterlockedExchangePointer(&nmtbl[mli], ntbl);
|
||||
|
@ -622,9 +622,9 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
(void)InterlockedExchangePointer(&HandleTable->Table[tli], nmtbl);
|
||||
}
|
||||
|
||||
/* increment the NextIndexNeedingPool to the next index where we need to
|
||||
/* increment the NextHandleNeedingPool to the next index where we need to
|
||||
allocate new memory */
|
||||
HandleTable->NextIndexNeedingPool += N_SUBHANDLE_ENTRIES;
|
||||
HandleTable->NextHandleNeedingPool += N_SUBHANDLE_ENTRIES;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -651,9 +651,9 @@ ExpFreeHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
/* automatically unlock the entry if currently locked. We however don't notify
|
||||
anyone who waited on the handle because we're holding an exclusive lock after
|
||||
all and these locks will fail then */
|
||||
(void)InterlockedExchangePointer(&Entry->u1.Object, NULL);
|
||||
Entry->u2.NextFreeTableEntry = HandleTable->FirstFreeTableEntry;
|
||||
HandleTable->FirstFreeTableEntry = Handle;
|
||||
(void)InterlockedExchangePointer(&Entry->Object, NULL);
|
||||
Entry->NextFreeTableEntry = HandleTable->FirstFree;
|
||||
HandleTable->FirstFree = Handle;
|
||||
|
||||
HandleTable->HandleCount--;
|
||||
}
|
||||
|
@ -678,11 +678,11 @@ ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
eli = ELI_FROM_HANDLE(Handle);
|
||||
|
||||
mlp = HandleTable->Table[tli];
|
||||
if(Handle < HandleTable->NextIndexNeedingPool &&
|
||||
mlp != NULL && mlp[mli] != NULL && mlp[mli][eli].u1.Object != NULL)
|
||||
if(Handle < HandleTable->NextHandleNeedingPool &&
|
||||
mlp != NULL && mlp[mli] != NULL && mlp[mli][eli].Object != NULL)
|
||||
{
|
||||
Entry = &mlp[mli][eli];
|
||||
DPRINT("handle lookup 0x%x -> entry 0x%p [HT:0x%p] ptr: 0x%p\n", Handle, Entry, HandleTable, mlp[mli][eli].u1.Object);
|
||||
DPRINT("handle lookup 0x%x -> entry 0x%p [HT:0x%p] ptr: 0x%p\n", Handle, Entry, HandleTable, mlp[mli][eli].Object);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -708,7 +708,7 @@ ExLockHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
|
||||
for(;;)
|
||||
{
|
||||
Current = (volatile ULONG_PTR)Entry->u1.Object;
|
||||
Current = (volatile ULONG_PTR)Entry->Object;
|
||||
|
||||
if(!Current || (HandleTable->Flags & EX_HANDLE_TABLE_CLOSING))
|
||||
{
|
||||
|
@ -719,7 +719,7 @@ ExLockHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
if(!(Current & EX_HANDLE_ENTRY_LOCKED))
|
||||
{
|
||||
New = Current | EX_HANDLE_ENTRY_LOCKED;
|
||||
if(InterlockedCompareExchangePointer(&Entry->u1.Object,
|
||||
if(InterlockedCompareExchangePointer(&Entry->Object,
|
||||
(PVOID)New,
|
||||
(PVOID)Current) == (PVOID)Current)
|
||||
{
|
||||
|
@ -756,13 +756,13 @@ ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
|
||||
DPRINT("ExUnlockHandleTableEntry HT:0x%p Entry:0x%p\n", HandleTable, Entry);
|
||||
|
||||
Current = (volatile ULONG_PTR)Entry->u1.Object;
|
||||
Current = (volatile ULONG_PTR)Entry->Object;
|
||||
|
||||
ASSERT(Current & EX_HANDLE_ENTRY_LOCKED);
|
||||
|
||||
New = Current & ~EX_HANDLE_ENTRY_LOCKED;
|
||||
|
||||
(void)InterlockedExchangePointer(&Entry->u1.Object,
|
||||
(void)InterlockedExchangePointer(&Entry->Object,
|
||||
(PVOID)New);
|
||||
|
||||
/* we unlocked the entry, pulse the contention event so threads who're waiting
|
||||
|
@ -784,13 +784,13 @@ ExCreateHandle(IN PHANDLE_TABLE HandleTable,
|
|||
ASSERT(HandleTable);
|
||||
ASSERT(Entry);
|
||||
|
||||
/* The highest bit in Entry->u1.Object has to be 1 so we make sure it's a
|
||||
/* The highest bit in Entry->Object has to be 1 so we make sure it's a
|
||||
pointer to kmode memory. It will cleared though because it also indicates
|
||||
the lock */
|
||||
ASSERT((ULONG_PTR)Entry->u1.Object & EX_HANDLE_ENTRY_LOCKED);
|
||||
ASSERT((ULONG_PTR)Entry->Object & EX_HANDLE_ENTRY_LOCKED);
|
||||
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireHandleTableLockExclusive(HandleTable);
|
||||
ExAcquireHandleLockExclusive(HandleTable);
|
||||
|
||||
NewHandleTableEntry = ExpAllocateHandleTableEntry(HandleTable,
|
||||
&Handle);
|
||||
|
@ -802,7 +802,7 @@ ExCreateHandle(IN PHANDLE_TABLE HandleTable,
|
|||
NewHandleTableEntry);
|
||||
}
|
||||
|
||||
ExReleaseHandleTableLock(HandleTable);
|
||||
ExReleaseHandleLock(HandleTable);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
return Handle;
|
||||
|
@ -823,7 +823,7 @@ ExDestroyHandle(IN PHANDLE_TABLE HandleTable,
|
|||
ExHandle = HANDLE_TO_EX_HANDLE(Handle);
|
||||
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireHandleTableLockExclusive(HandleTable);
|
||||
ExAcquireHandleLockExclusive(HandleTable);
|
||||
|
||||
HandleTableEntry = ExpLookupHandleTableEntry(HandleTable,
|
||||
ExHandle);
|
||||
|
@ -838,7 +838,7 @@ ExDestroyHandle(IN PHANDLE_TABLE HandleTable,
|
|||
Ret = TRUE;
|
||||
}
|
||||
|
||||
ExReleaseHandleTableLock(HandleTable);
|
||||
ExReleaseHandleLock(HandleTable);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
return Ret;
|
||||
|
@ -855,12 +855,12 @@ ExDestroyHandleByEntry(IN PHANDLE_TABLE HandleTable,
|
|||
ASSERT(Entry);
|
||||
|
||||
/* This routine requires the entry to be locked */
|
||||
ASSERT((ULONG_PTR)Entry->u1.Object & EX_HANDLE_ENTRY_LOCKED);
|
||||
ASSERT((ULONG_PTR)Entry->Object & EX_HANDLE_ENTRY_LOCKED);
|
||||
|
||||
DPRINT("DestroyHandleByEntry HT:0x%p Entry:0x%p\n", HandleTable, Entry);
|
||||
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireHandleTableLockExclusive(HandleTable);
|
||||
ExAcquireHandleLockExclusive(HandleTable);
|
||||
|
||||
/* free and automatically unlock the handle. However we don't need to pulse
|
||||
the contention event since other locks on this entry will fail */
|
||||
|
@ -868,7 +868,7 @@ ExDestroyHandleByEntry(IN PHANDLE_TABLE HandleTable,
|
|||
Entry,
|
||||
HANDLE_TO_EX_HANDLE(Handle));
|
||||
|
||||
ExReleaseHandleTableLock(HandleTable);
|
||||
ExReleaseHandleLock(HandleTable);
|
||||
KeLeaveCriticalRegion();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ extern POBJECT_TYPE ExEventPairObjectType;
|
|||
#define EX_OBJ_TO_HDR(eob) ((PROS_OBJECT_HEADER)((ULONG_PTR)(eob) & \
|
||||
~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \
|
||||
EX_HANDLE_ENTRY_AUDITONCLOSE)))
|
||||
#define EX_HTE_TO_HDR(hte) ((PROS_OBJECT_HEADER)((ULONG_PTR)((hte)->u1.Object) & \
|
||||
#define EX_HTE_TO_HDR(hte) ((PROS_OBJECT_HEADER)((ULONG_PTR)((hte)->Object) & \
|
||||
~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \
|
||||
EX_HANDLE_ENTRY_AUDITONCLOSE)))
|
||||
|
||||
|
|
|
@ -123,8 +123,8 @@ ObpQueryHandleAttributes(HANDLE Handle,
|
|||
Handle);
|
||||
if (HandleTableEntry != NULL)
|
||||
{
|
||||
HandleInfo->Inherit = (HandleTableEntry->u1.ObAttributes & EX_HANDLE_ENTRY_INHERITABLE) != 0;
|
||||
HandleInfo->ProtectFromClose = (HandleTableEntry->u1.ObAttributes & EX_HANDLE_ENTRY_PROTECTFROMCLOSE) != 0;
|
||||
HandleInfo->Inherit = (HandleTableEntry->ObAttributes & EX_HANDLE_ENTRY_INHERITABLE) != 0;
|
||||
HandleInfo->ProtectFromClose = (HandleTableEntry->ObAttributes & EX_HANDLE_ENTRY_PROTECTFROMCLOSE) != 0;
|
||||
|
||||
ExUnlockHandleTableEntry(Process->ObjectTable,
|
||||
HandleTableEntry);
|
||||
|
@ -183,14 +183,14 @@ ObpSetHandleAttributes(HANDLE Handle,
|
|||
if (HandleTableEntry != NULL)
|
||||
{
|
||||
if (HandleInfo->Inherit)
|
||||
HandleTableEntry->u1.ObAttributes |= EX_HANDLE_ENTRY_INHERITABLE;
|
||||
HandleTableEntry->ObAttributes |= EX_HANDLE_ENTRY_INHERITABLE;
|
||||
else
|
||||
HandleTableEntry->u1.ObAttributes &= ~EX_HANDLE_ENTRY_INHERITABLE;
|
||||
HandleTableEntry->ObAttributes &= ~EX_HANDLE_ENTRY_INHERITABLE;
|
||||
|
||||
if (HandleInfo->ProtectFromClose)
|
||||
HandleTableEntry->u1.ObAttributes |= EX_HANDLE_ENTRY_PROTECTFROMCLOSE;
|
||||
HandleTableEntry->ObAttributes |= EX_HANDLE_ENTRY_PROTECTFROMCLOSE;
|
||||
else
|
||||
HandleTableEntry->u1.ObAttributes &= ~EX_HANDLE_ENTRY_PROTECTFROMCLOSE;
|
||||
HandleTableEntry->ObAttributes &= ~EX_HANDLE_ENTRY_PROTECTFROMCLOSE;
|
||||
|
||||
/* FIXME: Do we need to set anything in the object header??? */
|
||||
|
||||
|
@ -231,7 +231,7 @@ ObpDeleteHandle(HANDLE Handle)
|
|||
Handle);
|
||||
if(HandleEntry != NULL)
|
||||
{
|
||||
if(HandleEntry->u1.ObAttributes & EX_HANDLE_ENTRY_PROTECTFROMCLOSE)
|
||||
if(HandleEntry->ObAttributes & EX_HANDLE_ENTRY_PROTECTFROMCLOSE)
|
||||
{
|
||||
ExUnlockHandleTableEntry(ObjectTable,
|
||||
HandleEntry);
|
||||
|
@ -316,17 +316,17 @@ ObDuplicateObject(PEPROCESS SourceProcess,
|
|||
ObjectHeader = EX_HTE_TO_HDR(SourceHandleEntry);
|
||||
ObjectBody = &ObjectHeader->Body;
|
||||
|
||||
NewHandleEntry.u1.Object = SourceHandleEntry->u1.Object;
|
||||
NewHandleEntry.Object = SourceHandleEntry->Object;
|
||||
if(HandleAttributes & OBJ_INHERIT)
|
||||
NewHandleEntry.u1.ObAttributes |= EX_HANDLE_ENTRY_INHERITABLE;
|
||||
NewHandleEntry.ObAttributes |= EX_HANDLE_ENTRY_INHERITABLE;
|
||||
else
|
||||
NewHandleEntry.u1.ObAttributes &= ~EX_HANDLE_ENTRY_INHERITABLE;
|
||||
NewHandleEntry.u2.GrantedAccess = ((Options & DUPLICATE_SAME_ACCESS) ?
|
||||
SourceHandleEntry->u2.GrantedAccess :
|
||||
NewHandleEntry.ObAttributes &= ~EX_HANDLE_ENTRY_INHERITABLE;
|
||||
NewHandleEntry.GrantedAccess = ((Options & DUPLICATE_SAME_ACCESS) ?
|
||||
SourceHandleEntry->GrantedAccess :
|
||||
DesiredAccess);
|
||||
if (Options & DUPLICATE_SAME_ACCESS)
|
||||
{
|
||||
NewHandleEntry.u2.GrantedAccess = SourceHandleEntry->u2.GrantedAccess;
|
||||
NewHandleEntry.GrantedAccess = SourceHandleEntry->GrantedAccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -335,7 +335,7 @@ ObDuplicateObject(PEPROCESS SourceProcess,
|
|||
RtlMapGenericMask(&DesiredAccess,
|
||||
&ObjectHeader->Type->TypeInfo.GenericMapping);
|
||||
}
|
||||
NewHandleEntry.u2.GrantedAccess = DesiredAccess;
|
||||
NewHandleEntry.GrantedAccess = DesiredAccess;
|
||||
}
|
||||
|
||||
/* reference the object so it doesn't get deleted after releasing the lock
|
||||
|
@ -634,7 +634,7 @@ DuplicateHandleCallback(PHANDLE_TABLE HandleTable,
|
|||
|
||||
PAGED_CODE();
|
||||
|
||||
Ret = (HandleTableEntry->u1.ObAttributes & EX_HANDLE_ENTRY_INHERITABLE) != 0;
|
||||
Ret = (HandleTableEntry->ObAttributes & EX_HANDLE_ENTRY_INHERITABLE) != 0;
|
||||
if(Ret)
|
||||
{
|
||||
ObjectHeader = EX_HTE_TO_HDR(HandleTableEntry);
|
||||
|
@ -739,12 +739,12 @@ ObpCreateHandle(PVOID ObjectBody,
|
|||
&ObjectHeader->Type->TypeInfo.GenericMapping);
|
||||
}
|
||||
|
||||
NewEntry.u1.Object = ObjectHeader;
|
||||
NewEntry.Object = ObjectHeader;
|
||||
if(HandleAttributes & OBJ_INHERIT)
|
||||
NewEntry.u1.ObAttributes |= EX_HANDLE_ENTRY_INHERITABLE;
|
||||
NewEntry.ObAttributes |= EX_HANDLE_ENTRY_INHERITABLE;
|
||||
else
|
||||
NewEntry.u1.ObAttributes &= ~EX_HANDLE_ENTRY_INHERITABLE;
|
||||
NewEntry.u2.GrantedAccess = GrantedAccess;
|
||||
NewEntry.ObAttributes &= ~EX_HANDLE_ENTRY_INHERITABLE;
|
||||
NewEntry.GrantedAccess = GrantedAccess;
|
||||
|
||||
if ((HandleAttributes & OBJ_KERNEL_HANDLE) &&
|
||||
ExGetPreviousMode == KernelMode)
|
||||
|
@ -834,7 +834,7 @@ ObQueryObjectAuditingByHandle(IN HANDLE Handle,
|
|||
Handle);
|
||||
if(HandleEntry != NULL)
|
||||
{
|
||||
*GenerateOnClose = (HandleEntry->u1.ObAttributes & EX_HANDLE_ENTRY_AUDITONCLOSE) != 0;
|
||||
*GenerateOnClose = (HandleEntry->ObAttributes & EX_HANDLE_ENTRY_AUDITONCLOSE) != 0;
|
||||
|
||||
ExUnlockHandleTableEntry(Process->ObjectTable,
|
||||
HandleEntry);
|
||||
|
@ -1013,7 +1013,7 @@ ObReferenceObjectByHandle(HANDLE Handle,
|
|||
&BODY_TO_HEADER(ObjectBody)->Type->TypeInfo.GenericMapping);
|
||||
}
|
||||
|
||||
GrantedAccess = HandleEntry->u2.GrantedAccess;
|
||||
GrantedAccess = HandleEntry->GrantedAccess;
|
||||
|
||||
/* Unless running as KernelMode, deny access if caller desires more access
|
||||
rights than the handle can grant */
|
||||
|
@ -1036,7 +1036,7 @@ ObReferenceObjectByHandle(HANDLE Handle,
|
|||
|
||||
ObReferenceObject(ObjectBody);
|
||||
|
||||
Attributes = HandleEntry->u1.ObAttributes & (EX_HANDLE_ENTRY_PROTECTFROMCLOSE |
|
||||
Attributes = HandleEntry->ObAttributes & (EX_HANDLE_ENTRY_PROTECTFROMCLOSE |
|
||||
EX_HANDLE_ENTRY_INHERITABLE |
|
||||
EX_HANDLE_ENTRY_AUDITONCLOSE);
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount,
|
|||
}
|
||||
|
||||
/* Check for synchronize access */
|
||||
GrantedAccess = HandleEntry->u2.GrantedAccess;
|
||||
GrantedAccess = HandleEntry->GrantedAccess;
|
||||
if ((PreviousMode != KernelMode) && (!(GrantedAccess & SYNCHRONIZE)))
|
||||
{
|
||||
/* Unlock the entry and fail */
|
||||
|
|
|
@ -383,8 +383,8 @@ PspCreateProcess(OUT PHANDLE ProcessHandle,
|
|||
|
||||
/* Create a handle for the Process */
|
||||
DPRINT("Initialzing Process CID Handle\n");
|
||||
CidEntry.u1.Object = Process;
|
||||
CidEntry.u2.GrantedAccess = 0;
|
||||
CidEntry.Object = Process;
|
||||
CidEntry.GrantedAccess = 0;
|
||||
Process->UniqueProcessId = ExCreateHandle(PspCidTable, &CidEntry);
|
||||
DPRINT("Created CID: %d\n", Process->UniqueProcessId);
|
||||
if(!Process->UniqueProcessId)
|
||||
|
@ -499,7 +499,7 @@ PsLookupProcessByProcessId(IN HANDLE ProcessId,
|
|||
ProcessId)))
|
||||
{
|
||||
/* Get the Process */
|
||||
FoundProcess = CidEntry->u1.Object;
|
||||
FoundProcess = CidEntry->Object;
|
||||
|
||||
/* Make sure it's really a process */
|
||||
if (FoundProcess->Pcb.Header.Type == ProcessObject)
|
||||
|
@ -541,7 +541,7 @@ PsLookupProcessThreadByCid(IN PCLIENT_ID Cid,
|
|||
Cid->UniqueThread)))
|
||||
{
|
||||
/* Get the Process */
|
||||
FoundThread = CidEntry->u1.Object;
|
||||
FoundThread = CidEntry->Object;
|
||||
|
||||
/* Make sure it's really a thread and this process' */
|
||||
if ((FoundThread->Tcb.DispatcherHeader.Type == ThreadObject) &&
|
||||
|
|
|
@ -306,8 +306,8 @@ PspPostInitSystemProcess(VOID)
|
|||
ObCreateHandleTable(NULL, FALSE, PsInitialSystemProcess);
|
||||
ObpKernelHandleTable = PsInitialSystemProcess->ObjectTable;
|
||||
|
||||
CidEntry.u1.Object = PsInitialSystemProcess;
|
||||
CidEntry.u2.GrantedAccess = 0;
|
||||
CidEntry.Object = PsInitialSystemProcess;
|
||||
CidEntry.GrantedAccess = 0;
|
||||
PsInitialSystemProcess->UniqueProcessId = ExCreateHandle(PspCidTable, &CidEntry);
|
||||
|
||||
if(!PsInitialSystemProcess->UniqueProcessId)
|
||||
|
|
|
@ -182,8 +182,8 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
|
|||
|
||||
/* Create Cid Handle */
|
||||
DPRINT("Creating Thread Handle (CID)\n");
|
||||
CidEntry.u1.Object = Thread;
|
||||
CidEntry.u2.GrantedAccess = 0;
|
||||
CidEntry.Object = Thread;
|
||||
CidEntry.GrantedAccess = 0;
|
||||
Thread->Cid.UniqueThread = ExCreateHandle(PspCidTable, &CidEntry);
|
||||
if (!Thread->Cid.UniqueThread) {
|
||||
|
||||
|
@ -378,7 +378,7 @@ PsLookupThreadByThreadId(IN HANDLE ThreadId,
|
|||
ThreadId)))
|
||||
{
|
||||
/* Get the Process */
|
||||
FoundThread = CidEntry->u1.Object;
|
||||
FoundThread = CidEntry->Object;
|
||||
|
||||
/* Make sure it's really a process */
|
||||
if (FoundThread->Tcb.DispatcherHeader.Type == ThreadObject)
|
||||
|
|
|
@ -292,8 +292,8 @@ RtlpCreateAtomHandle(PRTL_ATOM_TABLE AtomTable, PRTL_ATOM_TABLE_ENTRY Entry)
|
|||
HANDLE Handle;
|
||||
USHORT HandleIndex;
|
||||
|
||||
ExEntry.u1.Object = Entry;
|
||||
ExEntry.u2.GrantedAccess = 0x1; /* FIXME - valid handle */
|
||||
ExEntry.Object = Entry;
|
||||
ExEntry.GrantedAccess = 0x1; /* FIXME - valid handle */
|
||||
|
||||
Handle = ExCreateHandle(AtomTable->ExHandleTable,
|
||||
&ExEntry);
|
||||
|
@ -330,7 +330,7 @@ RtlpGetAtomEntry(PRTL_ATOM_TABLE AtomTable, ULONG Index)
|
|||
(HANDLE)((ULONG_PTR)Index << 2));
|
||||
if (ExEntry != NULL)
|
||||
{
|
||||
Entry = ExEntry->u1.Object;
|
||||
Entry = ExEntry->Object;
|
||||
|
||||
ExUnlockHandleTableEntry(AtomTable->ExHandleTable,
|
||||
ExEntry);
|
||||
|
|
Loading…
Reference in a new issue