ReactOS 0.4.17-dev-573-g8315b8c
name.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for name.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI FsRtlAreNamesEqual (IN PCUNICODE_STRING Name1, IN PCUNICODE_STRING Name2, IN BOOLEAN IgnoreCase, IN PCWCH UpcaseTable OPTIONAL)
 
VOID NTAPI FsRtlDissectName (IN UNICODE_STRING Name, OUT PUNICODE_STRING FirstPart, OUT PUNICODE_STRING RemainingPart)
 
BOOLEAN NTAPI FsRtlDoesNameContainWildCards (IN PUNICODE_STRING Name)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file name.c.

Function Documentation

◆ FsRtlAreNamesEqual()

BOOLEAN NTAPI FsRtlAreNamesEqual ( IN PCUNICODE_STRING  Name1,
IN PCUNICODE_STRING  Name2,
IN BOOLEAN  IgnoreCase,
IN PCWCH UpcaseTable  OPTIONAL 
)

Definition at line 45 of file name.c.

49{
50 UNICODE_STRING UpcaseName1;
51 UNICODE_STRING UpcaseName2;
52 BOOLEAN StringsAreEqual, MemoryAllocated = FALSE;
53 USHORT i;
55 PAGED_CODE();
56
57 /* Well, first check their size */
58 if (Name1->Length != Name2->Length) return FALSE;
59
60 /* Check if the caller didn't give an upcase table */
61 if ((IgnoreCase) && !(UpcaseTable))
62 {
63 /* Upcase the string ourselves */
64 Status = RtlUpcaseUnicodeString(&UpcaseName1, Name1, TRUE);
66
67 /* Upcase the second string too */
68 Status = RtlUpcaseUnicodeString(&UpcaseName2, Name2, TRUE);
69 if (!NT_SUCCESS(Status))
70 {
71 RtlFreeUnicodeString(&UpcaseName1);
73 }
74
75 Name1 = &UpcaseName1;
76 Name2 = &UpcaseName2;
77
78 /* Make sure we go through the path below, but free the strings */
81 }
82
83 /* Do a case-sensitive search */
84 if (!IgnoreCase)
85 {
86 /* Use a raw memory compare */
87 StringsAreEqual = RtlEqualMemory(Name1->Buffer,
89 Name1->Length);
90
91 /* Check if we allocated strings */
93 {
94 /* Free them */
95 RtlFreeUnicodeString(&UpcaseName1);
96 RtlFreeUnicodeString(&UpcaseName2);
97 }
98
99 /* Return the equality */
100 return StringsAreEqual;
101 }
102 else
103 {
104 /* Case in-sensitive search */
105 for (i = 0; i < Name1->Length / sizeof(WCHAR); i++)
106 {
107 /* Check if the character matches */
108 if (UpcaseTable[Name1->Buffer[i]] != UpcaseTable[Name2->Buffer[i]])
109 {
110 /* Non-match found! */
111 return FALSE;
112 }
113 }
114
115 /* We finished the loop so we are equal */
116 return TRUE;
117 }
118}
#define PAGED_CODE()
static _In_ PUNICODE_STRING _In_ BOOLEAN _In_opt_ PWCH UpcaseTable
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
#define IgnoreCase
Definition: cdprocs.h:461
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
_Must_inspect_result_ _In_ PCUNICODE_STRING Name2
Definition: fsrtlfuncs.h:796
Status
Definition: gdiplustypes.h:24
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
short WCHAR
Definition: pedump.c:58
unsigned short USHORT
Definition: pedump.c:61
_Out_ PSECURITY_DESCRIPTOR _Out_ PBOOLEAN MemoryAllocated
Definition: obfuncs.h:24

Referenced by Ext2SetLinkInfo(), Ext2SetRenameInfo(), FatSetRenameInfo(), file_create(), FindFile(), registry_load_volume_options(), registry_mark_volume_unmounted_path(), and VfatSetRenameInformation().

◆ FsRtlDissectName()

VOID NTAPI FsRtlDissectName ( IN UNICODE_STRING  Name,
OUT PUNICODE_STRING  FirstPart,
OUT PUNICODE_STRING  RemainingPart 
)

Definition at line 147 of file name.c.

150{
151 USHORT FirstPosition, i;
152 USHORT SkipFirstSlash = 0;
153 PAGED_CODE();
154
155 /* Zero the strings before continuing */
158
159 /* Just quit if the string is empty */
160 if (!Name.Length) return;
161
162 /* Find first backslash */
163 FirstPosition = Name.Length / sizeof(WCHAR) ;
164 for (i = 0; i < Name.Length / sizeof(WCHAR); i++)
165 {
166 /* If we found one... */
167 if (Name.Buffer[i] == L'\\')
168 {
169 /* If it begins string, just notice it and continue */
170 if (i == 0)
171 {
172 SkipFirstSlash = 1;
173 }
174 else
175 {
176 /* Else, save its position and break out of the loop */
177 FirstPosition = i;
178 break;
179 }
180 }
181 }
182
183 /* Set up the first result string */
184 FirstPart->Buffer = Name.Buffer + SkipFirstSlash;
185 FirstPart->Length = (FirstPosition - SkipFirstSlash) * sizeof(WCHAR);
187
188 /* And second one, if necessary */
189 if (FirstPosition < (Name.Length / sizeof(WCHAR)))
190 {
191 RemainingPart->Buffer = Name.Buffer + FirstPosition + 1;
192 RemainingPart->Length = Name.Length - (FirstPosition + 1) * sizeof(WCHAR);
194 }
195}
LPWSTR Name
Definition: desk.c:124
#define L(x)
Definition: resources.c:13
_Out_ PANSI_STRING _Out_ PANSI_STRING RemainingPart
Definition: fsrtlfuncs.h:379
_Out_ PANSI_STRING FirstPart
Definition: fsrtlfuncs.h:378
USHORT MaximumLength
Definition: env_spec_w32.h:377
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by AddFileName(), Ext2CreateFile(), NtfsLookupFileAt(), and START_TEST().

◆ FsRtlDoesNameContainWildCards()

BOOLEAN NTAPI FsRtlDoesNameContainWildCards ( IN PUNICODE_STRING  Name)

Definition at line 213 of file name.c.

214{
215 PWCHAR Ptr;
216 PAGED_CODE();
217
218 /* Loop through every character */
219 if (Name->Length)
220 {
221 Ptr = Name->Buffer + (Name->Length / sizeof(WCHAR)) - 1;
222 while ((Ptr >= Name->Buffer) && (*Ptr != L'\\'))
223 {
224 /* Check for Wildcard */
226 Ptr--;
227 }
228 }
229
230 /* Nothing Found */
231 return FALSE;
232}
#define FsRtlIsUnicodeCharacterWild(C)
Definition: fsrtlfuncs.h:1636
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
uint16_t * PWCHAR
Definition: typedefs.h:56

Referenced by CdInitializeEnumeration(), Ext2CreateFile(), Ext2FillEntry(), Ext2QueryDirectory(), Ext2SetLinkInfo(), Ext2SetRenameInfo(), FindFile(), query_directory(), RxCanonicalizeNameAndObtainNetRoot(), RxQueryDirectory(), and UDFQueryDirectory().