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