Author: fireball
Date: Wed Aug 12 13:42:34 2009
New Revision: 42635
URL:
http://svn.reactos.org/svn/reactos?rev=42635&view=rev
Log:
- Rewrite RtlpCreateAtomHandle to readable code and fix a problem spotted in bug 4788.
Modified:
trunk/reactos/ntoskrnl/rtl/libsupp.c
Modified: trunk/reactos/ntoskrnl/rtl/libsupp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/libsupp.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/rtl/libsupp.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/rtl/libsupp.c [iso-8859-1] Wed Aug 12 13:42:34 2009
@@ -516,29 +516,36 @@
HANDLE Handle;
USHORT HandleIndex;
+ /* Initialize ex handle table entry */
ExEntry.Object = Entry;
ExEntry.GrantedAccess = 0x1; /* FIXME - valid handle */
+ /* Create ex handle */
Handle = ExCreateHandle(AtomTable->ExHandleTable,
- &ExEntry);
- if (Handle != NULL)
+ &ExEntry);
+ if (!Handle) return FALSE;
+
+ /* Calculate HandleIndex (by getting rid of the first two bits) */
+ HandleIndex = (USHORT)((ULONG_PTR)Handle >> 2);
+
+ /* Index must be less than 0xC000 */
+ if (HandleIndex >= 0xC000)
{
- HandleIndex = (USHORT)((ULONG_PTR)Handle >> 2);
- /* FIXME - Handle Indexes >= 0xC000 ?! */
- if ((ULONG_PTR)HandleIndex >> 2 < 0xC000)
- {
- Entry->HandleIndex = HandleIndex;
- Entry->Atom = 0xC000 + HandleIndex;
-
- return TRUE;
- }
- else
- ExDestroyHandle(AtomTable->ExHandleTable,
- Handle,
- NULL);
+ /* Destroy ex handle */
+ ExDestroyHandle(AtomTable->ExHandleTable,
+ Handle,
+ NULL);
+
+ /* Return failure */
+ return FALSE;
}
- return FALSE;
+ /* Initialize atom table entry */
+ Entry->HandleIndex = HandleIndex;
+ Entry->Atom = 0xC000 + HandleIndex;
+
+ /* Return success */
+ return TRUE;
}
PRTL_ATOM_TABLE_ENTRY