mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
directly translate handles to indexes in ex/handle.c
svn path=/trunk/; revision=17191
This commit is contained in:
parent
ebe277b796
commit
afcb29cc7c
8 changed files with 63 additions and 74 deletions
|
@ -77,6 +77,11 @@ static LARGE_INTEGER ExpHandleShortWait;
|
|||
#define IS_VALID_EX_HANDLE(index) \
|
||||
(((index) & ~VALID_HANDLE_MASK) == 0)
|
||||
|
||||
#define HANDLE_TO_EX_HANDLE(handle) \
|
||||
(LONG)(((LONG)(handle) >> 2) - 1)
|
||||
#define EX_HANDLE_TO_HANDLE(exhandle) \
|
||||
(HANDLE)(((exhandle) + 1) << 2)
|
||||
|
||||
static BOOLEAN ExpInitialized = FALSE;
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -491,7 +496,7 @@ freehandletable:
|
|||
|
||||
static PHANDLE_TABLE_ENTRY
|
||||
ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
||||
OUT PLONG Handle)
|
||||
OUT PHANDLE Handle)
|
||||
{
|
||||
PHANDLE_TABLE_ENTRY Entry = NULL;
|
||||
|
||||
|
@ -520,7 +525,7 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
|
||||
Entry = &HandleTable->Table[tli][mli][eli];
|
||||
|
||||
*Handle = HandleTable->FirstFreeTableEntry;
|
||||
*Handle = EX_HANDLE_TO_HANDLE(HandleTable->FirstFreeTableEntry);
|
||||
|
||||
/* save the index to the next free handle (if available) */
|
||||
HandleTable->FirstFreeTableEntry = Entry->u2.NextFreeTableEntry;
|
||||
|
@ -629,7 +634,7 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
Entry->u1.ObAttributes = EX_HANDLE_ENTRY_LOCKED;
|
||||
Entry->u2.NextFreeTableEntry = 0;
|
||||
|
||||
*Handle = HandleTable->NextIndexNeedingPool;
|
||||
*Handle = EX_HANDLE_TO_HANDLE(HandleTable->NextIndexNeedingPool);
|
||||
|
||||
HandleTable->HandleCount++;
|
||||
|
||||
|
@ -803,12 +808,12 @@ ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|||
FALSE);
|
||||
}
|
||||
|
||||
LONG
|
||||
HANDLE
|
||||
ExCreateHandle(IN PHANDLE_TABLE HandleTable,
|
||||
IN PHANDLE_TABLE_ENTRY Entry)
|
||||
{
|
||||
PHANDLE_TABLE_ENTRY NewHandleTableEntry;
|
||||
LONG Handle = EX_INVALID_HANDLE;
|
||||
HANDLE Handle = NULL;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -841,20 +846,23 @@ ExCreateHandle(IN PHANDLE_TABLE HandleTable,
|
|||
|
||||
BOOLEAN
|
||||
ExDestroyHandle(IN PHANDLE_TABLE HandleTable,
|
||||
IN LONG Handle)
|
||||
IN HANDLE Handle)
|
||||
{
|
||||
PHANDLE_TABLE_ENTRY HandleTableEntry;
|
||||
LONG ExHandle;
|
||||
BOOLEAN Ret = FALSE;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
ASSERT(HandleTable);
|
||||
|
||||
ExHandle = HANDLE_TO_EX_HANDLE(Handle);
|
||||
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireHandleTableLockExclusive(HandleTable);
|
||||
|
||||
HandleTableEntry = ExpLookupHandleTableEntry(HandleTable,
|
||||
Handle);
|
||||
ExHandle);
|
||||
|
||||
if(HandleTableEntry != NULL && ExLockHandleTableEntry(HandleTable, HandleTableEntry))
|
||||
{
|
||||
|
@ -862,7 +870,7 @@ ExDestroyHandle(IN PHANDLE_TABLE HandleTable,
|
|||
the contention event since other locks on this entry will fail */
|
||||
ExpFreeHandleTableEntry(HandleTable,
|
||||
HandleTableEntry,
|
||||
Handle);
|
||||
ExHandle);
|
||||
Ret = TRUE;
|
||||
}
|
||||
|
||||
|
@ -875,7 +883,7 @@ ExDestroyHandle(IN PHANDLE_TABLE HandleTable,
|
|||
VOID
|
||||
ExDestroyHandleByEntry(IN PHANDLE_TABLE HandleTable,
|
||||
IN PHANDLE_TABLE_ENTRY Entry,
|
||||
IN LONG Handle)
|
||||
IN HANDLE Handle)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -894,7 +902,7 @@ ExDestroyHandleByEntry(IN PHANDLE_TABLE HandleTable,
|
|||
the contention event since other locks on this entry will fail */
|
||||
ExpFreeHandleTableEntry(HandleTable,
|
||||
Entry,
|
||||
Handle);
|
||||
HANDLE_TO_EX_HANDLE(Handle));
|
||||
|
||||
ExReleaseHandleTableLock(HandleTable);
|
||||
KeLeaveCriticalRegion();
|
||||
|
@ -902,7 +910,7 @@ ExDestroyHandleByEntry(IN PHANDLE_TABLE HandleTable,
|
|||
|
||||
PHANDLE_TABLE_ENTRY
|
||||
ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable,
|
||||
IN LONG Handle)
|
||||
IN HANDLE Handle)
|
||||
{
|
||||
PHANDLE_TABLE_ENTRY HandleTableEntry;
|
||||
|
||||
|
@ -911,7 +919,7 @@ ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable,
|
|||
ASSERT(HandleTable);
|
||||
|
||||
HandleTableEntry = ExpLookupHandleTableEntry(HandleTable,
|
||||
Handle);
|
||||
HANDLE_TO_EX_HANDLE(Handle));
|
||||
if (HandleTableEntry != NULL && ExLockHandleTableEntry(HandleTable, HandleTableEntry))
|
||||
{
|
||||
DPRINT("ExMapHandleToPointer HT:0x%p Entry:0x%p locked\n", HandleTable, HandleTableEntry);
|
||||
|
@ -923,7 +931,7 @@ ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable,
|
|||
|
||||
BOOLEAN
|
||||
ExChangeHandle(IN PHANDLE_TABLE HandleTable,
|
||||
IN LONG Handle,
|
||||
IN HANDLE Handle,
|
||||
IN PEX_CHANGE_HANDLE_CALLBACK ChangeHandleCallback,
|
||||
IN PVOID Context)
|
||||
{
|
||||
|
@ -938,7 +946,7 @@ ExChangeHandle(IN PHANDLE_TABLE HandleTable,
|
|||
KeEnterCriticalRegion();
|
||||
|
||||
HandleTableEntry = ExpLookupHandleTableEntry(HandleTable,
|
||||
Handle);
|
||||
HANDLE_TO_EX_HANDLE(Handle));
|
||||
|
||||
if(HandleTableEntry != NULL && ExLockHandleTableEntry(HandleTable, HandleTableEntry))
|
||||
{
|
||||
|
|
|
@ -86,8 +86,6 @@ ExpInitializeProfileImplementation(VOID);
|
|||
|
||||
#define EX_HANDLE_TABLE_CLOSING 0x1
|
||||
|
||||
#define EX_INVALID_HANDLE (~0)
|
||||
|
||||
#define EX_HANDLE_ENTRY_FLAGSMASK (EX_HANDLE_ENTRY_LOCKED | \
|
||||
EX_HANDLE_ENTRY_PROTECTFROMCLOSE | \
|
||||
EX_HANDLE_ENTRY_INHERITABLE | \
|
||||
|
@ -145,7 +143,7 @@ ExUnlockHandleTableEntry(
|
|||
IN PHANDLE_TABLE_ENTRY Entry
|
||||
);
|
||||
|
||||
LONG
|
||||
HANDLE
|
||||
ExCreateHandle(
|
||||
IN PHANDLE_TABLE HandleTable,
|
||||
IN PHANDLE_TABLE_ENTRY Entry
|
||||
|
@ -154,26 +152,26 @@ ExCreateHandle(
|
|||
BOOLEAN
|
||||
ExDestroyHandle(
|
||||
IN PHANDLE_TABLE HandleTable,
|
||||
IN LONG Handle
|
||||
IN HANDLE Handle
|
||||
);
|
||||
|
||||
VOID
|
||||
ExDestroyHandleByEntry(
|
||||
IN PHANDLE_TABLE HandleTable,
|
||||
IN PHANDLE_TABLE_ENTRY Entry,
|
||||
IN LONG Handle
|
||||
IN HANDLE Handle
|
||||
);
|
||||
|
||||
PHANDLE_TABLE_ENTRY
|
||||
ExMapHandleToPointer(
|
||||
IN PHANDLE_TABLE HandleTable,
|
||||
IN LONG Handle
|
||||
IN HANDLE Handle
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
ExChangeHandle(
|
||||
IN PHANDLE_TABLE HandleTable,
|
||||
IN LONG Handle,
|
||||
IN HANDLE Handle,
|
||||
IN PEX_CHANGE_HANDLE_CALLBACK ChangeHandleCallback,
|
||||
IN PVOID Context
|
||||
);
|
||||
|
|
|
@ -62,11 +62,6 @@ enum
|
|||
|
||||
#define OBJECT_ALLOC_SIZE(ObjectSize) ((ObjectSize)+sizeof(OBJECT_HEADER))
|
||||
|
||||
#define HANDLE_TO_EX_HANDLE(handle) \
|
||||
(LONG)(((LONG)(handle) >> 2) - 1)
|
||||
#define EX_HANDLE_TO_HANDLE(exhandle) \
|
||||
(HANDLE)(((exhandle) + 1) << 2)
|
||||
|
||||
extern PDIRECTORY_OBJECT NameSpaceRoot;
|
||||
extern POBJECT_TYPE ObSymbolicLinkType;
|
||||
extern PHANDLE_TABLE ObpKernelHandleTable;
|
||||
|
|
|
@ -90,7 +90,6 @@ ObpQueryHandleAttributes(HANDLE Handle,
|
|||
{
|
||||
PHANDLE_TABLE HandleTable;
|
||||
PHANDLE_TABLE_ENTRY HandleTableEntry;
|
||||
LONG ExHandle;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -99,18 +98,17 @@ ObpQueryHandleAttributes(HANDLE Handle,
|
|||
if(ObIsKernelHandle(Handle, ExGetPreviousMode()))
|
||||
{
|
||||
HandleTable = ObpKernelHandleTable;
|
||||
ExHandle = HANDLE_TO_EX_HANDLE(ObKernelHandleToHandle(Handle));
|
||||
Handle = ObKernelHandleToHandle(Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleTable = PsGetCurrentProcess()->ObjectTable;
|
||||
ExHandle = HANDLE_TO_EX_HANDLE(Handle);
|
||||
}
|
||||
|
||||
KeEnterCriticalRegion();
|
||||
|
||||
HandleTableEntry = ExMapHandleToPointer(HandleTable,
|
||||
ExHandle);
|
||||
Handle);
|
||||
if (HandleTableEntry == NULL)
|
||||
{
|
||||
KeLeaveCriticalRegion();
|
||||
|
@ -135,7 +133,6 @@ ObpSetHandleAttributes(HANDLE Handle,
|
|||
{
|
||||
PHANDLE_TABLE HandleTable;
|
||||
PHANDLE_TABLE_ENTRY HandleTableEntry;
|
||||
LONG ExHandle;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -144,18 +141,17 @@ ObpSetHandleAttributes(HANDLE Handle,
|
|||
if(ObIsKernelHandle(Handle, ExGetPreviousMode()))
|
||||
{
|
||||
HandleTable = ObpKernelHandleTable;
|
||||
ExHandle = HANDLE_TO_EX_HANDLE(ObKernelHandleToHandle(Handle));
|
||||
Handle = ObKernelHandleToHandle(Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleTable = PsGetCurrentProcess()->ObjectTable;
|
||||
ExHandle = HANDLE_TO_EX_HANDLE(Handle);
|
||||
}
|
||||
|
||||
KeEnterCriticalRegion();
|
||||
|
||||
HandleTableEntry = ExMapHandleToPointer(HandleTable,
|
||||
ExHandle);
|
||||
Handle);
|
||||
if (HandleTableEntry == NULL)
|
||||
{
|
||||
KeLeaveCriticalRegion();
|
||||
|
@ -190,7 +186,6 @@ ObpDeleteHandle(PHANDLE_TABLE HandleTable,
|
|||
PHANDLE_TABLE_ENTRY HandleEntry;
|
||||
PVOID Body;
|
||||
POBJECT_HEADER ObjectHeader;
|
||||
LONG ExHandle = HANDLE_TO_EX_HANDLE(Handle);
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -199,7 +194,7 @@ ObpDeleteHandle(PHANDLE_TABLE HandleTable,
|
|||
KeEnterCriticalRegion();
|
||||
|
||||
HandleEntry = ExMapHandleToPointer(HandleTable,
|
||||
ExHandle);
|
||||
Handle);
|
||||
if(HandleEntry != NULL)
|
||||
{
|
||||
if(HandleEntry->u1.ObAttributes & EX_HANDLE_ENTRY_PROTECTFROMCLOSE)
|
||||
|
@ -220,7 +215,7 @@ ObpDeleteHandle(PHANDLE_TABLE HandleTable,
|
|||
/* destroy and unlock the handle entry */
|
||||
ExDestroyHandleByEntry(HandleTable,
|
||||
HandleEntry,
|
||||
ExHandle);
|
||||
Handle);
|
||||
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
|
@ -245,9 +240,8 @@ ObDuplicateObject(PEPROCESS SourceProcess,
|
|||
HANDLE_TABLE_ENTRY NewHandleEntry;
|
||||
PVOID ObjectBody;
|
||||
POBJECT_HEADER ObjectHeader;
|
||||
LONG ExTargetHandle;
|
||||
LONG ExSourceHandle;
|
||||
ULONG NewHandleCount;
|
||||
HANDLE NewTargetHandle;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -261,12 +255,10 @@ ObDuplicateObject(PEPROCESS SourceProcess,
|
|||
SourceHandleTable = SourceProcess->ObjectTable;
|
||||
}
|
||||
|
||||
ExSourceHandle = HANDLE_TO_EX_HANDLE(SourceHandle);
|
||||
|
||||
KeEnterCriticalRegion();
|
||||
|
||||
SourceHandleEntry = ExMapHandleToPointer(SourceHandleTable,
|
||||
ExSourceHandle);
|
||||
SourceHandle);
|
||||
if (SourceHandleEntry == NULL)
|
||||
{
|
||||
KeLeaveCriticalRegion();
|
||||
|
@ -316,9 +308,9 @@ ObDuplicateObject(PEPROCESS SourceProcess,
|
|||
KeLeaveCriticalRegion();
|
||||
|
||||
/* attempt to create the new handle */
|
||||
ExTargetHandle = ExCreateHandle(TargetProcess->ObjectTable,
|
||||
NewTargetHandle = ExCreateHandle(TargetProcess->ObjectTable,
|
||||
&NewHandleEntry);
|
||||
if (ExTargetHandle != EX_INVALID_HANDLE)
|
||||
if (NewTargetHandle != NULL)
|
||||
{
|
||||
if (Options & DUPLICATE_CLOSE_SOURCE)
|
||||
{
|
||||
|
@ -328,7 +320,7 @@ ObDuplicateObject(PEPROCESS SourceProcess,
|
|||
|
||||
ObDereferenceObject(ObjectBody);
|
||||
|
||||
*TargetHandle = EX_HANDLE_TO_HANDLE(ExTargetHandle);
|
||||
*TargetHandle = NewTargetHandle;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -607,7 +599,7 @@ ObpCreateHandle(PEPROCESS Process,
|
|||
{
|
||||
HANDLE_TABLE_ENTRY NewEntry;
|
||||
POBJECT_HEADER ObjectHeader;
|
||||
LONG ExHandle;
|
||||
HANDLE Handle;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -639,10 +631,10 @@ ObpCreateHandle(PEPROCESS Process,
|
|||
NewEntry.u1.ObAttributes &= ~EX_HANDLE_ENTRY_INHERITABLE;
|
||||
NewEntry.u2.GrantedAccess = GrantedAccess;
|
||||
|
||||
ExHandle = ExCreateHandle(Process->ObjectTable,
|
||||
Handle = ExCreateHandle(Process->ObjectTable,
|
||||
&NewEntry);
|
||||
DPRINT("ObCreateHandle(0x%x)==0x%x [HT:0x%x]\n", ObjectHeader, *HandleReturn, Process->ObjectTable);
|
||||
if(ExHandle != EX_INVALID_HANDLE)
|
||||
DPRINT("ObCreateHandle(0x%x)==0x%x [HT:0x%x]\n", ObjectHeader, Handle, Process->ObjectTable);
|
||||
if(Handle != NULL)
|
||||
{
|
||||
if(InterlockedIncrement(&ObjectHeader->HandleCount) == 1)
|
||||
{
|
||||
|
@ -652,7 +644,7 @@ ObpCreateHandle(PEPROCESS Process,
|
|||
UserMode);
|
||||
}
|
||||
|
||||
*HandleReturn = EX_HANDLE_TO_HANDLE(ExHandle);
|
||||
*HandleReturn = Handle;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -670,7 +662,6 @@ ObQueryObjectAuditingByHandle(IN HANDLE Handle,
|
|||
{
|
||||
PHANDLE_TABLE_ENTRY HandleEntry;
|
||||
PEPROCESS Process;
|
||||
LONG ExHandle = HANDLE_TO_EX_HANDLE(Handle);
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -681,7 +672,7 @@ ObQueryObjectAuditingByHandle(IN HANDLE Handle,
|
|||
KeEnterCriticalRegion();
|
||||
|
||||
HandleEntry = ExMapHandleToPointer(Process->ObjectTable,
|
||||
ExHandle);
|
||||
Handle);
|
||||
if(HandleEntry != NULL)
|
||||
{
|
||||
*GenerateOnClose = (HandleEntry->u1.ObAttributes & EX_HANDLE_ENTRY_AUDITONCLOSE) != 0;
|
||||
|
@ -729,7 +720,6 @@ ObReferenceObjectByHandle(HANDLE Handle,
|
|||
PVOID ObjectBody;
|
||||
ACCESS_MASK GrantedAccess;
|
||||
ULONG Attributes;
|
||||
LONG ExHandle;
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
|
@ -800,18 +790,17 @@ ObReferenceObjectByHandle(HANDLE Handle,
|
|||
if(ObIsKernelHandle(Handle, AccessMode))
|
||||
{
|
||||
HandleTable = ObpKernelHandleTable;
|
||||
ExHandle = HANDLE_TO_EX_HANDLE(ObKernelHandleToHandle(Handle));
|
||||
Handle = ObKernelHandleToHandle(Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleTable = PsGetCurrentProcess()->ObjectTable;
|
||||
ExHandle = HANDLE_TO_EX_HANDLE(Handle);
|
||||
}
|
||||
|
||||
KeEnterCriticalRegion();
|
||||
|
||||
HandleEntry = ExMapHandleToPointer(HandleTable,
|
||||
ExHandle);
|
||||
Handle);
|
||||
if (HandleEntry == NULL)
|
||||
{
|
||||
KeLeaveCriticalRegion();
|
||||
|
|
|
@ -38,7 +38,6 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount,
|
|||
POBJECT_HEADER ObjectHeader;
|
||||
PHANDLE_TABLE HandleTable;
|
||||
ACCESS_MASK GrantedAccess;
|
||||
LONG ExHandle;
|
||||
PVOID DefaultObject;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
|
@ -120,17 +119,16 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount,
|
|||
{
|
||||
/* Use the System Handle Table and decode */
|
||||
HandleTable = ObpKernelHandleTable;
|
||||
ExHandle = HANDLE_TO_EX_HANDLE(ObKernelHandleToHandle(Handles[i]));
|
||||
Handles[i] = ObKernelHandleToHandle(Handles[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Use the Process' Handle table and get the Ex Handle */
|
||||
HandleTable = PsGetCurrentProcess()->ObjectTable;
|
||||
ExHandle = HANDLE_TO_EX_HANDLE(Handles[i]);
|
||||
}
|
||||
|
||||
/* Get a pointer to it */
|
||||
if (!(HandleEntry = ExMapHandleToPointer(HandleTable, ExHandle)))
|
||||
if (!(HandleEntry = ExMapHandleToPointer(HandleTable, Handles[i])))
|
||||
{
|
||||
DPRINT1("Invalid handle\n");
|
||||
Status = STATUS_INVALID_HANDLE;
|
||||
|
|
|
@ -480,7 +480,7 @@ PsLookupProcessByProcessId(IN HANDLE ProcessId,
|
|||
|
||||
/* Get the CID Handle Entry */
|
||||
if (!(CidEntry = ExMapHandleToPointer(PspCidTable,
|
||||
HANDLE_TO_EX_HANDLE(ProcessId))))
|
||||
ProcessId)))
|
||||
{
|
||||
/* Get the Process */
|
||||
FoundProcess = CidEntry->u1.Object;
|
||||
|
@ -518,7 +518,7 @@ PsLookupProcessThreadByCid(IN PCLIENT_ID Cid,
|
|||
|
||||
/* Get the CID Handle Entry */
|
||||
if (!(CidEntry = ExMapHandleToPointer(PspCidTable,
|
||||
HANDLE_TO_EX_HANDLE(Cid->UniqueThread))))
|
||||
Cid->UniqueThread)))
|
||||
{
|
||||
/* Get the Process */
|
||||
FoundThread = CidEntry->u1.Object;
|
||||
|
|
|
@ -377,7 +377,7 @@ PsLookupThreadByThreadId(IN HANDLE ThreadId,
|
|||
|
||||
/* Get the CID Handle Entry */
|
||||
if (!(CidEntry = ExMapHandleToPointer(PspCidTable,
|
||||
HANDLE_TO_EX_HANDLE(ThreadId))))
|
||||
ThreadId)))
|
||||
{
|
||||
/* Get the Process */
|
||||
FoundThread = CidEntry->u1.Object;
|
||||
|
@ -717,7 +717,6 @@ NtOpenThread(OUT PHANDLE ThreadHandle,
|
|||
if (ClientId->UniqueProcess)
|
||||
{
|
||||
/* Get the Process */
|
||||
if (ClientId->UniqueProcess == (HANDLE)-1) KEBUGCHECK(0);
|
||||
DPRINT("Opening by Process ID: %x\n", ClientId->UniqueProcess);
|
||||
Status = PsLookupProcessThreadByCid(ClientId,
|
||||
NULL,
|
||||
|
|
|
@ -246,33 +246,35 @@ VOID
|
|||
RtlpFreeAtomHandle(PRTL_ATOM_TABLE AtomTable, PRTL_ATOM_TABLE_ENTRY Entry)
|
||||
{
|
||||
ExDestroyHandle(AtomTable->ExHandleTable,
|
||||
(LONG)Entry->HandleIndex);
|
||||
(HANDLE)((ULONG_PTR)Entry->HandleIndex << 2));
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
RtlpCreateAtomHandle(PRTL_ATOM_TABLE AtomTable, PRTL_ATOM_TABLE_ENTRY Entry)
|
||||
{
|
||||
HANDLE_TABLE_ENTRY ExEntry;
|
||||
LONG HandleIndex;
|
||||
HANDLE Handle;
|
||||
USHORT HandleIndex;
|
||||
|
||||
ExEntry.u1.Object = Entry;
|
||||
ExEntry.u2.GrantedAccess = 0x1; /* FIXME - valid handle */
|
||||
|
||||
HandleIndex = ExCreateHandle(AtomTable->ExHandleTable,
|
||||
Handle = ExCreateHandle(AtomTable->ExHandleTable,
|
||||
&ExEntry);
|
||||
if (HandleIndex != EX_INVALID_HANDLE)
|
||||
HandleIndex = (USHORT)((ULONG_PTR)Handle >> 2);
|
||||
if (Handle != NULL)
|
||||
{
|
||||
/* FIXME - Handle Indexes >= 0xC000 ?! */
|
||||
if (HandleIndex < 0xC000)
|
||||
{
|
||||
Entry->HandleIndex = (USHORT)HandleIndex;
|
||||
Entry->Atom = 0xC000 + (USHORT)HandleIndex;
|
||||
Entry->HandleIndex = HandleIndex;
|
||||
Entry->Atom = 0xC000 + HandleIndex;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
ExDestroyHandle(AtomTable->ExHandleTable,
|
||||
HandleIndex);
|
||||
Handle);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -284,7 +286,7 @@ RtlpGetAtomEntry(PRTL_ATOM_TABLE AtomTable, ULONG Index)
|
|||
PHANDLE_TABLE_ENTRY ExEntry;
|
||||
|
||||
ExEntry = ExMapHandleToPointer(AtomTable->ExHandleTable,
|
||||
(LONG)Index);
|
||||
(HANDLE)((ULONG_PTR)Index << 2));
|
||||
if (ExEntry != NULL)
|
||||
{
|
||||
PRTL_ATOM_TABLE_ENTRY Entry;
|
||||
|
|
Loading…
Reference in a new issue