enter a critical region before looking up a CID handle

svn path=/trunk/; revision=17198
This commit is contained in:
Thomas Bluemel 2005-08-08 10:54:32 +00:00
parent da23cad0de
commit 1a2a435f9c
3 changed files with 20 additions and 6 deletions

View file

@ -478,6 +478,8 @@ PsLookupProcessByProcessId(IN HANDLE ProcessId,
NTSTATUS Status = STATUS_INVALID_PARAMETER;
PAGED_CODE();
KeEnterCriticalRegion();
/* Get the CID Handle Entry */
if ((CidEntry = ExMapHandleToPointer(PspCidTable,
ProcessId)))
@ -498,6 +500,8 @@ PsLookupProcessByProcessId(IN HANDLE ProcessId,
ExUnlockHandleTableEntry(PspCidTable, CidEntry);
}
KeLeaveCriticalRegion();
/* Return to caller */
return Status;
}
@ -516,6 +520,8 @@ PsLookupProcessThreadByCid(IN PCLIENT_ID Cid,
NTSTATUS Status = STATUS_INVALID_CID;
PAGED_CODE();
KeEnterCriticalRegion();
/* Get the CID Handle Entry */
if ((CidEntry = ExMapHandleToPointer(PspCidTable,
Cid->UniqueThread)))
@ -545,6 +551,8 @@ PsLookupProcessThreadByCid(IN PCLIENT_ID Cid,
ExUnlockHandleTableEntry(PspCidTable, CidEntry);
}
KeLeaveCriticalRegion();
/* Return to caller */
return Status;
}

View file

@ -375,6 +375,8 @@ PsLookupThreadByThreadId(IN HANDLE ThreadId,
NTSTATUS Status = STATUS_INVALID_PARAMETER;
PAGED_CODE();
KeEnterCriticalRegion();
/* Get the CID Handle Entry */
if ((CidEntry = ExMapHandleToPointer(PspCidTable,
ThreadId)))
@ -395,6 +397,8 @@ PsLookupThreadByThreadId(IN HANDLE ThreadId,
ExUnlockHandleTableEntry(PspCidTable, CidEntry);
}
KeLeaveCriticalRegion();
/* Return to caller */
return Status;
}

View file

@ -261,11 +261,11 @@ RtlpCreateAtomHandle(PRTL_ATOM_TABLE AtomTable, PRTL_ATOM_TABLE_ENTRY Entry)
Handle = ExCreateHandle(AtomTable->ExHandleTable,
&ExEntry);
HandleIndex = (USHORT)((ULONG_PTR)Handle >> 2);
if (Handle != NULL)
{
HandleIndex = (USHORT)((ULONG_PTR)Handle >> 2);
/* FIXME - Handle Indexes >= 0xC000 ?! */
if (HandleIndex < 0xC000)
if ((ULONG_PTR)HandleIndex >> 2 < 0xC000)
{
Entry->HandleIndex = HandleIndex;
Entry->Atom = 0xC000 + HandleIndex;
@ -284,21 +284,23 @@ PRTL_ATOM_TABLE_ENTRY
RtlpGetAtomEntry(PRTL_ATOM_TABLE AtomTable, ULONG Index)
{
PHANDLE_TABLE_ENTRY ExEntry;
PRTL_ATOM_TABLE_ENTRY Entry = NULL;
/* NOTE: There's no need to explicitly enter a critical region because it's
guaranteed that we're in a critical region right now (as we hold
the atom table lock) */
ExEntry = ExMapHandleToPointer(AtomTable->ExHandleTable,
(HANDLE)((ULONG_PTR)Index << 2));
if (ExEntry != NULL)
{
PRTL_ATOM_TABLE_ENTRY Entry;
Entry = ExEntry->u1.Object;
ExUnlockHandleTableEntry(AtomTable->ExHandleTable,
ExEntry);
return Entry;
}
return NULL;
return Entry;
}
/* FIXME - RtlpCreateUnicodeString is obsolete and should be removed ASAP! */