ReactOS 0.4.16-dev-297-gc569aee
namesup.cpp File Reference
#include "udffs.h"
Include dependency graph for namesup.cpp:

Go to the source code of this file.

Functions

PWCHAR __fastcall UDFDissectName (IN PWCHAR Buffer, OUT PUSHORT Length)
 
BOOLEAN __fastcall UDFIsNameValid (IN PUNICODE_STRING SearchPattern, OUT BOOLEAN *StreamOpen, OUT ULONG *SNameIndex)
 
BOOLEAN UDFIsNameInExpression (IN PVCB Vcb, IN PUNICODE_STRING FileName, IN PUNICODE_STRING PtrSearchPattern, OUT PBOOLEAN DosOpen, IN BOOLEAN IgnoreCase, IN BOOLEAN ContainsWC, IN BOOLEAN CanBe8dot3, IN BOOLEAN KeepIntact)
 
BOOLEAN __fastcall UDFIsMatchAllMask (IN PUNICODE_STRING Name, OUT BOOLEAN *DosOpen)
 
BOOLEAN __fastcall UDFCanNameBeA8dot3 (IN PUNICODE_STRING Name)
 

Function Documentation

◆ UDFCanNameBeA8dot3()

BOOLEAN __fastcall UDFCanNameBeA8dot3 ( IN PUNICODE_STRING  Name)

Definition at line 266 of file namesup.cpp.

269{
270 if(Name->Length >= 13 * sizeof(WCHAR))
271 return FALSE;
272
273 ULONG i,l;
274 ULONG dot_pos=0;
275 ULONG ext_len=0;
276 PWCHAR buff = Name->Buffer;
277
278 l = Name->Length / sizeof(WCHAR);
279
280 for(i=0; i<l; i++, buff++) {
281 if( ((*buff) == L'.') ||
282 ((*buff) == DOS_DOT) ) {
283 if(dot_pos)
284 return FALSE;
285 dot_pos = i+1;
286 } else
287 if(dot_pos) {
288 ext_len++;
289 if(ext_len > 3)
290 return FALSE;
291 } else
292 if(i >= 8) {
293 return FALSE;
294 }
295 }
296 return TRUE;
297} // end UDFCanNameBeA8dot3()
r l[0]
Definition: byte_order.h:168
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define DOS_DOT
Definition: env_spec_w32.h:914
static unsigned char buff[32768]
Definition: fatten.c:17
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 L(x)
Definition: ntvdm.h:50
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by UDFFindFile(), and UDFQueryDirectory().

◆ UDFDissectName()

PWCHAR __fastcall UDFDissectName ( IN PWCHAR  Buffer,
OUT PUSHORT  Length 
)

Definition at line 19 of file namesup.cpp.

23{
24
25 USHORT i;
26
27#if defined(_X86_) && defined(_MSC_VER) && !defined(__clang__)
28
29 PWCHAR retval;
30
31 __asm push ebx
32 __asm push ecx
33
34 __asm mov ebx,Buffer
35 __asm xor ecx,ecx
36Remove_leading_slash:
37 __asm cmp [word ptr ebx],L'\\'
38 __asm jne No_IncPointer
39 __asm add ebx,2
40 __asm jmp Remove_leading_slash
41No_IncPointer:
42 __asm cmp [word ptr ebx],L':'
43 __asm jne Scan_1
44 __asm add ebx,2
45 __asm inc ecx
46 __asm jmp EO_Dissect
47Scan_1:
48 __asm mov ax,[word ptr ebx]
49 __asm cmp ax,L'\\'
50 __asm je EO_Dissect
51 __asm or ax,ax
52 __asm jz EO_Dissect
53 __asm cmp ax,L':'
54 __asm jne Cont_scan
55 __asm or ecx,ecx
56 __asm jnz EO_Dissect
57Cont_scan:
58 __asm inc ecx
59 __asm add ebx,2
60 __asm jmp Scan_1
61EO_Dissect:
62 __asm mov retval,ebx
63 __asm mov i,cx
64
65 __asm pop ecx
66 __asm pop ebx
67
68 *Length = i;
69 return retval;
70
71#else // NO X86 optimization , use generic C/C++
72
73 while (Buffer[0] == L'\\') {
74 Buffer++;
75 }
76 if (Buffer[0] == L':') {
77 *Length = 1;
78 return &(Buffer[1]);
79 }
80 for(i = 0; ( Buffer[i] != L'\\' &&
81 ((Buffer[i] != L':') || !i) &&
82 Buffer[i]); i++);
83 *Length = i;
84 return &(Buffer[i]);
85
86#endif // _X86_
87
88} // end UDFDissectName()
Definition: bufpool.h:45
static void xor(unsigned char *dst, const unsigned char *a, const unsigned char *b, const int count)
Definition: crypt_des.c:251
const WCHAR * word
Definition: lex.c:36
static PVOID ptr
Definition: dispmode.c:27
#define cmp(status, error)
Definition: error.c:114
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
unsigned short USHORT
Definition: pedump.c:61
_Out_opt_ int * cx
Definition: commctrl.h:585
static calc_node_t * pop(void)
Definition: rpn_ieee.c:90
static void push(calc_node_t *op)
Definition: rpn_ieee.c:113
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl ebx
Definition: synth_sse3d.h:83
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx testl eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx shrl ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 psrlq mm1 psrlq mm5 paddd mm0 paddd mm4 psrad mm0 psrad mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx andl ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 psrlq mm1 paddd mm0 psrad mm0 packssdw mm0 movd eax movw ax
Definition: synth_sse3d.h:180

Referenced by UDFCommonCreate(), and UDFIsPathnameValid().

◆ UDFIsMatchAllMask()

BOOLEAN __fastcall UDFIsMatchAllMask ( IN PUNICODE_STRING  Name,
OUT BOOLEAN DosOpen 
)

Definition at line 214 of file namesup.cpp.

218{
219 USHORT i;
221
222 if(DosOpen)
223 *DosOpen = FALSE;
224 Buffer = Name->Buffer;
225 if(Name->Length == sizeof(WCHAR)) {
226 // Win32-style wildcard
227 if((*Buffer) != L'*')
228 return FALSE;
229 return TRUE;
230 } else
231 if(Name->Length == sizeof(WCHAR)*(8+1+3)) {
232 // DOS-style wildcard
233 for(i=0;i<8;i++,Buffer++) {
234 if((*Buffer) != DOS_QM)
235 return FALSE;
236 }
237 if((*Buffer) != DOS_DOT)
238 return FALSE;
239 Buffer++;
240 for(i=9;i<12;i++,Buffer++) {
241 if((*Buffer) != DOS_QM)
242 return FALSE;
243 }
244 if(DosOpen)
245 *DosOpen = TRUE;
246 return TRUE;
247 } else
248 if(Name->Length == sizeof(WCHAR)*(3)) {
249 // DOS-style wildcard
250 if(Buffer[0] != DOS_STAR)
251 return FALSE;
252 if(Buffer[1] != DOS_DOT)
253 return FALSE;
254 if(Buffer[2] != DOS_STAR)
255 return FALSE;
256 if(DosOpen)
257 *DosOpen = TRUE;
258 return TRUE;
259 } else {
260 return FALSE;
261 }
262} // end UDFIsMatchAllMask()
#define DOS_STAR
Definition: env_spec_w32.h:912
#define DOS_QM
Definition: env_spec_w32.h:913

Referenced by UDFQueryDirectory().

◆ UDFIsNameInExpression()

BOOLEAN UDFIsNameInExpression ( IN PVCB  Vcb,
IN PUNICODE_STRING  FileName,
IN PUNICODE_STRING  PtrSearchPattern,
OUT PBOOLEAN  DosOpen,
IN BOOLEAN  IgnoreCase,
IN BOOLEAN  ContainsWC,
IN BOOLEAN  CanBe8dot3,
IN BOOLEAN  KeepIntact 
)

Definition at line 156 of file namesup.cpp.

166{
167 BOOLEAN Match = TRUE;
169 WCHAR Buffer[13];
170
171 if(!PtrSearchPattern) return TRUE;
172 // we try to open file by LFN by default
173 if(DosOpen) (*DosOpen) = FALSE;
174 // If there are wildcards in the expression then we call the
175 // appropriate FsRtlRoutine.
176 if(ContainsWC) {
177 Match = FsRtlIsNameInExpression( PtrSearchPattern, FileName, IgnoreCase, NULL );
178 // Otherwise do a direct memory comparison for the name string.
179 } else if (RtlCompareUnicodeString(FileName, PtrSearchPattern, IgnoreCase)) {
180 Match = FALSE;
181 }
182
183 if(Match) return TRUE;
184
185 // check if SFN can match this pattern
186 if(!CanBe8dot3)
187 return FALSE;
188
189 // try to open by SFN
190 ShortName.Buffer = (PWCHAR)(&Buffer);
191 ShortName.MaximumLength = 13*sizeof(WCHAR);
192 UDFDOSName(Vcb, &ShortName, FileName, KeepIntact);
193
194 // PtrSearchPattern is upcased if we are called with IgnoreCase=TRUE
195 // DOSName is always upcased
196 // thus, we can use case-sensetive compare here to improve performance
197 if(ContainsWC) {
198 Match = FsRtlIsNameInExpression( PtrSearchPattern, &ShortName, FALSE, NULL );
199 // Otherwise do a direct memory comparison for the name string.
200 } else if (!RtlCompareUnicodeString(&ShortName, PtrSearchPattern, FALSE)) {
201 Match = TRUE;
202 }
203 if(DosOpen && Match) {
204 // remember that we've opened file by SFN
205 (*DosOpen) = TRUE;
206 }
207 return Match;
208} // end UDFIsNameInExpression()
unsigned char BOOLEAN
#define ContainsWC
#define IgnoreCase
Definition: cdprocs.h:461
#define CanBe8dot3
#define NULL
Definition: types.h:112
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING ShortName
Definition: fatprocs.h:1307
BOOLEAN NTAPI FsRtlIsNameInExpression(IN PUNICODE_STRING Expression, IN PUNICODE_STRING Name, IN BOOLEAN IgnoreCase, IN PWCHAR UpcaseTable OPTIONAL)
Definition: name.c:514
#define Vcb
Definition: cdprocs.h:1415
void __fastcall UDFDOSName(IN PVCB Vcb, IN OUT PUNICODE_STRING DosName, IN PUNICODE_STRING UdfName, IN BOOLEAN KeepIntact)
Definition: udf_info.cpp:427

Referenced by UDFFindNextMatch().

◆ UDFIsNameValid()

BOOLEAN __fastcall UDFIsNameValid ( IN PUNICODE_STRING  SearchPattern,
OUT BOOLEAN StreamOpen,
OUT ULONG SNameIndex 
)

Definition at line 92 of file namesup.cpp.

96 {
97 LONG Index, l;
98 BOOLEAN _StreamOpen = FALSE;
100 WCHAR c, c0;
101
102 if(StreamOpen) (*StreamOpen) = FALSE;
103 // We can't create nameless file or too long path
104 if(!(l = SearchPattern->Length/sizeof(WCHAR)) ||
105 (l>UDF_X_PATH_LEN)) return FALSE;
106 Buffer = SearchPattern->Buffer;
107 for(Index = 0; Index<l; Index++, Buffer++) {
108 // Check for disallowed characters
109 c = (*Buffer);
110 if((c == L'*') ||
111 (c == L'>') ||
112 (c == L'\"') ||
113 (c == L'/') ||
114 (c == L'<') ||
115 (c == L'|') ||
116 ((c >= 0x0000) && (c <= 0x001f)) ||
117 (c == L'?')) return FALSE;
118 // check if this a Stream path (& validate it)
119 if(!(_StreamOpen) && // sub-streams are not allowed
120 (Index<(l-1)) && // stream name must be specified
121 ((_StreamOpen) = (c == L':'))) {
122 if(StreamOpen) (*StreamOpen) = TRUE;
123 if(SNameIndex) (*SNameIndex) = Index;
124 }
125 // According to NT IFS documentation neither SPACE nor DOT can be
126 // a trailing character
127 if(Index && (c == L'\\') ) {
128 if((c0 == L' ') ||
129 (_StreamOpen) || // stream is not a directory
130 (c0 == L'.')) return FALSE;
131 }
132 c0 = c;
133 }
134 // According to NT IFS documentation neither SPACE nor DOT can be
135 // a trailing character
136 if((c0 == L' ') ||
137 (c0 == L'.')) return FALSE;
138 return TRUE;
139} // end UDFIsNameValid()
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
long LONG
Definition: pedump.c:60
#define UDF_X_PATH_LEN
Definition: udffs.h:33
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by UDFCommonCreate(), and UDFIsPathnameValid().