[ros-diffs] [pschweitzer] 37046: FsRtlIsNameInExpression: - Get rid of stupid helper FsRtlpUpcaseUnicodeChar - Use a wrapper (FsRtlIsNameInExpressionPrivate) to uppercase Name when needed (and not expression, it mustn't be uppercased by the function!) - Move most of the code to FsRtlIsNameInExpressionPrivate Be carrefull, with that commit, FsRtlIsNameInExpression calls must be done inside a PSEH block.

pschweitzer at svn.reactos.org pschweitzer at svn.reactos.org
Wed Oct 29 10:10:03 CET 2008


Author: pschweitzer
Date: Wed Oct 29 04:10:03 2008
New Revision: 37046

URL: http://svn.reactos.org/svn/reactos?rev=37046&view=rev
Log:
FsRtlIsNameInExpression:
- Get rid of stupid helper FsRtlpUpcaseUnicodeChar
- Use a wrapper (FsRtlIsNameInExpressionPrivate) to uppercase Name when needed (and not expression, it mustn't be uppercased by the function!)
- Move most of the code to FsRtlIsNameInExpressionPrivate

Be carrefull, with that commit, FsRtlIsNameInExpression calls must be done inside a PSEH block.

Modified:
    branches/pierre-fsd/ntoskrnl/fsrtl/name.c

Modified: branches/pierre-fsd/ntoskrnl/fsrtl/name.c
URL: http://svn.reactos.org/svn/reactos/branches/pierre-fsd/ntoskrnl/fsrtl/name.c?rev=37046&r1=37045&r2=37046&view=diff
==============================================================================
--- branches/pierre-fsd/ntoskrnl/fsrtl/name.c [iso-8859-1] (original)
+++ branches/pierre-fsd/ntoskrnl/fsrtl/name.c [iso-8859-1] Wed Oct 29 04:10:03 2008
@@ -16,24 +16,51 @@
 
 /* PRIVATE FUNCTIONS *********************************************************/
 
-WCHAR
-NTAPI
-FsRtlpUpcaseUnicodeChar(IN WCHAR SourceCharacter,
-                        IN BOOLEAN IgnoreCase,
-                        IN PWCHAR UpcaseTable OPTIONAL)
-{
-    if (IgnoreCase)
-    {
-        if (!UpcaseTable)
-        {
-            return RtlUpcaseUnicodeChar(SourceCharacter);
+BOOLEAN
+NTAPI
+FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression,
+                               IN PUNICODE_STRING Name,
+                               IN BOOLEAN IgnoreCase,
+                               IN PWCHAR UpcaseTable OPTIONAL)
+{
+    ULONG i, j, k = 0;
+	
+    ASSERT(!FsRtlDoesNameContainWildCards(Name));
+
+    for (i = 0 ; i < Expression->Length / sizeof(WCHAR) ; i++)
+    {
+        if ((Expression->Buffer[i] == (IgnoreCase ? UpcaseTable[Name->Buffer[k]] : Name->Buffer[k])) ||
+            (Expression->Buffer[i] == L'?') || (Expression->Buffer[i] == DOS_QM) ||
+            (Expression->Buffer[i] == DOS_DOT && (Name->Buffer[k] == L'.' || Name->Buffer[k] == L'0')))
+        {
+            k++;
+        }
+        else if (Expression->Buffer[i] == L'*')
+        {
+            k = Name->Length / sizeof(WCHAR);
+        }
+        else if (Expression->Buffer[i] == DOS_STAR)
+        {
+            for (j = k ; j < Name->Length / sizeof(WCHAR) ; j++)
+            {
+                if (Name->Buffer[j] == L'.')
+                {
+                    k = j;
+                    break;
+                }
+            }
         }
         else
         {
-            return UpcaseTable[SourceCharacter];
-        }
-    }
-    return SourceCharacter;
+            k = 0;
+        }
+        if (k >= Expression->Length / sizeof(WCHAR))
+        {
+            return TRUE;
+        }
+    }
+
+    return FALSE;
 }
 
 /* PUBLIC FUNCTIONS **********************************************************/
@@ -250,7 +277,8 @@
  * Check if the Name string is in the Expression string.
  *
  * @param Expression
- *        The string in which we've to find Name. It can contain wildcards
+ *        The string in which we've to find Name. It can contain wildcards.
+ *        If IgnoreCase is set to TRUE, this string MUST BE uppercase. 
  *
  * @param Name
  *        The string to find. It cannot contain wildcards
@@ -276,43 +304,31 @@
                         IN BOOLEAN IgnoreCase,
                         IN PWCHAR UpcaseTable OPTIONAL)
 {
-    ULONG i, j, k = 0;
-	
-    ASSERT(!FsRtlDoesNameContainWildCards(Name));
-
-    for (i = 0 ; i < Expression->Length / sizeof(WCHAR) ; i++)
-    {
-        if ((FsRtlpUpcaseUnicodeChar(Expression->Buffer[i], IgnoreCase, UpcaseTable) ==
-             FsRtlpUpcaseUnicodeChar(Name->Buffer[k], IgnoreCase, UpcaseTable)) ||
-            (Expression->Buffer[i] == L'?') || (Expression->Buffer[i] == DOS_QM) ||
-            (Expression->Buffer[i] == DOS_DOT && (Name->Buffer[k] == L'.' || Name->Buffer[k] == L'0')))
-        {
-            k++;
-        }
-        else if (Expression->Buffer[i] == L'*')
-        {
-            k = Name->Length / sizeof(WCHAR);
-        }
-        else if (Expression->Buffer[i] == DOS_STAR)
-        {
-            for (j = k ; j < Name->Length / sizeof(WCHAR) ; j++)
-            {
-                if (Name->Buffer[j] == L'.')
-                {
-                    k = j;
-                    break;
-                }
-            }
-        }
-        else
-        {
-            k = 0;
-        }
-        if (k >= Expression->Length / sizeof(WCHAR))
-        {
-            return TRUE;
-        }
-    }
-
-    return FALSE;
-}
+    BOOLEAN Result;
+    NTSTATUS Status;
+    UNICODE_STRING IntName;
+
+    if (IgnoreCase && !UpcaseTable)
+    {
+        Status = RtlUpcaseUnicodeString(&IntName, Name, TRUE);
+        if (Status != STATUS_SUCCESS)
+        {
+            ExRaiseStatus(Status);
+        }
+        Name = &IntName;
+        IgnoreCase = FALSE;
+    }
+    else
+    {
+        IntName.Buffer = NULL;
+    }
+
+    Result = FsRtlIsNameInExpressionPrivate(Expression, Name, IgnoreCase, UpcaseTable);
+
+    if (IntName.Buffer != NULL)
+    {
+        RtlFreeUnicodeString(&IntName);
+    }
+
+    return Result;
+}



More information about the Ros-diffs mailing list