enter a critical region before looking up a CID handle
Modified: trunk/reactos/ntoskrnl/ps/process.c
Modified: trunk/reactos/ntoskrnl/ps/thread.c
Modified: trunk/reactos/ntoskrnl/rtl/libsupp.c
_____
Modified: trunk/reactos/ntoskrnl/ps/process.c
--- trunk/reactos/ntoskrnl/ps/process.c 2005-08-08 10:41:34 UTC (rev
17197)
+++ trunk/reactos/ntoskrnl/ps/process.c 2005-08-08 10:54:32 UTC (rev
17198)
@@ -477,6 +477,8 @@
PEPROCESS FoundProcess;
NTSTATUS Status = STATUS_INVALID_PARAMETER;
PAGED_CODE();
+
+ KeEnterCriticalRegion();
/* Get the CID Handle Entry */
if ((CidEntry = ExMapHandleToPointer(PspCidTable,
@@ -497,6 +499,8 @@
/* Unlock the Entry */
ExUnlockHandleTableEntry(PspCidTable, CidEntry);
}
+
+ KeLeaveCriticalRegion();
/* Return to caller */
return Status;
@@ -515,6 +519,8 @@
PETHREAD FoundThread;
NTSTATUS Status = STATUS_INVALID_CID;
PAGED_CODE();
+
+ KeEnterCriticalRegion();
/* Get the CID Handle Entry */
if ((CidEntry = ExMapHandleToPointer(PspCidTable,
@@ -544,6 +550,8 @@
/* Unlock the Entry */
ExUnlockHandleTableEntry(PspCidTable, CidEntry);
}
+
+ KeLeaveCriticalRegion();
/* Return to caller */
return Status;
_____
Modified: trunk/reactos/ntoskrnl/ps/thread.c
--- trunk/reactos/ntoskrnl/ps/thread.c 2005-08-08 10:41:34 UTC (rev
17197)
+++ trunk/reactos/ntoskrnl/ps/thread.c 2005-08-08 10:54:32 UTC (rev
17198)
@@ -374,6 +374,8 @@
PETHREAD FoundThread;
NTSTATUS Status = STATUS_INVALID_PARAMETER;
PAGED_CODE();
+
+ KeEnterCriticalRegion();
/* Get the CID Handle Entry */
if ((CidEntry = ExMapHandleToPointer(PspCidTable,
@@ -394,6 +396,8 @@
/* Unlock the Entry */
ExUnlockHandleTableEntry(PspCidTable, CidEntry);
}
+
+ KeLeaveCriticalRegion();
/* Return to caller */
return Status;
_____
Modified: trunk/reactos/ntoskrnl/rtl/libsupp.c
--- trunk/reactos/ntoskrnl/rtl/libsupp.c 2005-08-08 10:41:34 UTC
(rev 17197)
+++ trunk/reactos/ntoskrnl/rtl/libsupp.c 2005-08-08 10:54:32 UTC
(rev 17198)
@@ -261,11 +261,11 @@
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 @@
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! */