Fix kernel-mode executive atom implementation (mostly add SEH and tidy up the code...
[reactos.git] / reactos / lib / rtl / atom.c
index 4467f67..1c643df 100644 (file)
@@ -150,6 +150,9 @@ RtlCreateAtomTable(IN ULONG TableSize,
         return STATUS_SUCCESS;
      }
 
         return STATUS_SUCCESS;
      }
 
+   /* Use default if size was incorrect */
+   if (TableSize <= 1) TableSize = 37;
+
    /* allocate atom table */
    Table = RtlpAllocAtomTable(((TableSize - 1) * sizeof(PRTL_ATOM_TABLE_ENTRY)) +
                               sizeof(RTL_ATOM_TABLE));
    /* allocate atom table */
    Table = RtlpAllocAtomTable(((TableSize - 1) * sizeof(PRTL_ATOM_TABLE_ENTRY)) +
                               sizeof(RTL_ATOM_TABLE));
@@ -348,7 +351,7 @@ RtlAddAtomToAtomTable(IN PRTL_ATOM_TABLE AtomTable,
           {
              ULONG AtomNameLen = wcslen(AtomName);
              
           {
              ULONG AtomNameLen = wcslen(AtomName);
              
-             if (AtomNameLen > MAX_ATOM_LEN)
+             if (AtomNameLen > RTL_MAXIMUM_ATOM_LENGTH)
              {
                 Status = STATUS_INVALID_PARAMETER;
                 goto end;
              {
                 Status = STATUS_INVALID_PARAMETER;
                 goto end;
@@ -507,27 +510,22 @@ RtlLookupAtomInAtomTable(IN PRTL_ATOM_TABLE AtomTable,
      }
 
    RtlpLockAtomTable(AtomTable);
      }
 
    RtlpLockAtomTable(AtomTable);
-
    Status = STATUS_OBJECT_NAME_NOT_FOUND;
 
    /* string atom */
    Entry = RtlpHashAtomName(AtomTable,
                             AtomName,
                             &HashLink);
    Status = STATUS_OBJECT_NAME_NOT_FOUND;
 
    /* string atom */
    Entry = RtlpHashAtomName(AtomTable,
                             AtomName,
                             &HashLink);
-
    if (Entry != NULL)
      {
         Status = STATUS_SUCCESS;
         FoundAtom = (RTL_ATOM)Entry->Atom;
      }
    if (Entry != NULL)
      {
         Status = STATUS_SUCCESS;
         FoundAtom = (RTL_ATOM)Entry->Atom;
      }
-
    RtlpUnlockAtomTable(AtomTable);
    RtlpUnlockAtomTable(AtomTable);
-
    if (NT_SUCCESS(Status) && Atom != NULL)
      {
         *Atom = FoundAtom;
      }
    if (NT_SUCCESS(Status) && Atom != NULL)
      {
         *Atom = FoundAtom;
      }
-
    return Status;
 }
 
    return Status;
 }