1 /*
2  * PROJECT:         ReactOS kernel-mode tests
3  * LICENSE:         LGPLv2.1+ - See COPYING.LIB in the top level directory
4  * PURPOSE:         Test for FsRtlIsFatDbcsLegal/FsRtlIsHpfsDbcsLegal
5  * PROGRAMMER:      Thomas Faber <thomas.faber@reactos.org>
6  *                  Pierre Schweitzer <pierre@reactos.org>
7  */
8 
9 #include <kmt_test.h>
10 
11 static struct
12 {
13     PCSTR Dbcs;
14     BOOLEAN LegalFat;
15     BOOLEAN LegalHpfs;
16     BOOLEAN HasWildCards;
17     BOOLEAN IsPath;
18     BOOLEAN LeadingBackslash;
19 } NamesTests[] =
20 {
21     { "",                   FALSE, FALSE                      },
22     { "a",                  TRUE,  TRUE,  FALSE, FALSE, FALSE },
23     { "A",                  TRUE,  TRUE,  FALSE, FALSE, FALSE },
24     { ".",                  TRUE,  TRUE,  TRUE,  FALSE, FALSE },
25     { "..",                 TRUE,  TRUE,  TRUE,  FALSE, FALSE },
26     { "...",                FALSE, FALSE                      },
27     { "A ",                 FALSE, FALSE                      },
28     { " ",                  FALSE, FALSE                      },
29     { " A",                 TRUE,  TRUE,  FALSE, FALSE, FALSE },
30     { " A ",                FALSE, FALSE                      },
31     { "A.",                 FALSE, FALSE                      },
32     { ".A",                 FALSE, TRUE,  FALSE, FALSE, FALSE },
33     { ".A.",                FALSE, FALSE                      },
34     { "*",                  TRUE,  TRUE,  TRUE,  FALSE, FALSE },
35     { "?",                  TRUE,  TRUE,  TRUE,  FALSE, FALSE },
36     { "????????.???",       TRUE,  TRUE,  TRUE,  FALSE, FALSE },
37     { "????????????",       TRUE,  TRUE,  TRUE,  FALSE, FALSE },
38     { "????????.????",      TRUE,  TRUE,  TRUE,  FALSE, FALSE },
39     { "??????????????????", TRUE,  TRUE,  TRUE,  FALSE, FALSE },
40     { "?*?*?*?*?*?*?*?*?*", TRUE,  TRUE,  TRUE,  FALSE, FALSE },
41     { "ABCDEFGHIJKLMNOPQ*", TRUE,  TRUE,  TRUE,  FALSE, FALSE },
42     { "ABCDEFGHI\\*",       FALSE, TRUE,  TRUE,  TRUE,  FALSE },
43     { "*\\ABCDEFGHI",       FALSE, TRUE,  TRUE,  TRUE,  FALSE },
44     { "?.?.?",              TRUE,  TRUE,  TRUE,  FALSE, FALSE },
45     { "?..?",               TRUE,  TRUE,  TRUE,  FALSE, FALSE },
46     { "? ",                 TRUE,  FALSE, TRUE,  FALSE, FALSE },
47     { " ?",                 TRUE,  TRUE,  TRUE,  FALSE, FALSE },
48     { "?.",                 TRUE,  FALSE, TRUE,  FALSE, FALSE },
49     { ".?",                 TRUE,  TRUE,  TRUE,  FALSE, FALSE },
50     { "? .?",               TRUE,  TRUE,  TRUE,  FALSE, FALSE },
51     { "A?A",                TRUE,  TRUE,  TRUE,  FALSE, FALSE },
52     { "A*A",                TRUE,  TRUE,  TRUE,  FALSE, FALSE },
53     { "A<A",                TRUE,  TRUE,  TRUE,  FALSE, FALSE },
54     { "A>A",                TRUE,  TRUE,  TRUE,  FALSE, FALSE },
55     { "A\"A",               TRUE,  TRUE,  TRUE,  FALSE, FALSE },
56     { "A'A",                TRUE,  TRUE,  FALSE, FALSE, FALSE },
57     { "A:A",                FALSE, FALSE                      },
58     { "A\x1fG",             FALSE, FALSE                      },
59     { "A\x01G",             FALSE, FALSE                      },
60     { "A\x0aG",             FALSE, FALSE                      },
61     { "A\x0dG",             FALSE, FALSE                      },
62     { "\x7f",               TRUE,  TRUE,  FALSE, FALSE, FALSE },
63     /* FIXME: these two are probably locale-specific */
64     { "\x80",               TRUE,  TRUE,  FALSE, FALSE, FALSE },
65     { "\xff",               TRUE,  TRUE,  FALSE, FALSE, FALSE },
66     { "ABCDEFGH.IJK",       TRUE,  TRUE,  FALSE, FALSE, FALSE },
67     { "ABCDEFGHX.IJK",      FALSE, TRUE,  FALSE, FALSE, FALSE },
68     { "ABCDEFGHX.IJ",       FALSE, TRUE,  FALSE, FALSE, FALSE },
69     { "ABCDEFGH.IJKX",      FALSE, TRUE,  FALSE, FALSE, FALSE },
70     { "ABCDEFG.IJKX",       FALSE, TRUE,  FALSE, FALSE, FALSE },
71     { "ABCDEFGH",           TRUE, TRUE,  FALSE, FALSE, FALSE },
72     { "ABCDEFGHX",          FALSE, TRUE,  FALSE, FALSE, FALSE },
73     { "A.B",                TRUE,  TRUE,  FALSE, FALSE, FALSE },
74     { "A..B",               FALSE, TRUE,  FALSE, FALSE, FALSE },
75     { "A.B.",               FALSE, FALSE                      },
76     { "A.B.C",              FALSE, TRUE,  FALSE, FALSE, FALSE },
77     { "A .B",               FALSE, TRUE,  FALSE, FALSE, FALSE },
78     { " A .B",              FALSE, TRUE,  FALSE, FALSE, FALSE },
79     { "A. B",               TRUE,  TRUE,  FALSE, FALSE, FALSE },
80     { "A. B ",              FALSE, FALSE                      },
81     { "A. B ",              FALSE, FALSE                      },
82     { " A . B",             FALSE, TRUE,  FALSE, FALSE, FALSE },
83     { " A . B ",            FALSE, FALSE                      },
84     { "\\ABCDEFGH.IJK",     TRUE,  TRUE,  FALSE, FALSE, TRUE  },
85     { "ABCDEFGH.IJK\\",     TRUE,  TRUE,  FALSE, TRUE,  FALSE },
86     { "\\ABCDEFGH.IJK\\",   TRUE,  TRUE,  FALSE, TRUE,  TRUE  },
87     { "\\",                 TRUE,  TRUE,  FALSE, FALSE, TRUE  },
88     { "\\\\",               FALSE, FALSE                      },
89     { "\\\\B",              FALSE, FALSE                      },
90     { "A\\",                TRUE,  TRUE,  FALSE, TRUE,  FALSE },
91     { "A\\B",               TRUE,  TRUE,  FALSE, TRUE,  FALSE },
92     { "A\\\\",              FALSE, FALSE                      },
93     { "A\\\\B",             FALSE, FALSE                      },
94     /* We can exceed MAX_PATH (260) characters */
95     { "0BCDEF.HI\\1BCDEF.HI\\2BCDEF.HI\\3BCDEF.HI\\4BCDEF.HI\\5BCDEF.HI\\6BCDEF.HI\\7BCDEF.HI\\8BCDEF.HI\\9BCDEF.HI\\0BCDEF.HI\\1BCDEF.HI\\2BCDEF.HI\\3BCDEF.HI\\4BCDEF.HI\\5BCDEF.HI\\6BCDEF.HI\\7BCDEF.HI\\8BCDEF.HI\\9BCDEF.HI\\0BCDEF.HI\\1BCDEF.HI\\2BCDEF.HI\\3BCDEF.HI\\4BCDEF.HI\\5BCDEF.HI\\6BCDEF.HI",    TRUE,  TRUE,  FALSE, TRUE,  FALSE },
96     { "0BCDEF.HI\\1BCDEF.HI\\2BCDEF.HI\\3BCDEF.HI\\4BCDEF.HI\\5BCDEF.HI\\6BCDEF.HI\\7BCDEF.HI\\8BCDEF.HI\\9BCDEF.HI\\0BCDEF.HI\\1BCDEF.HI\\2BCDEF.HI\\3BCDEF.HI\\4BCDEF.HI\\5BCDEF.HI\\6BCDEF.HI\\7BCDEF.HI\\8BCDEF.HI\\9BCDEF.HI\\0BCDEF.HI\\1BCDEF.HI\\2BCDEF.HI\\3BCDEF.HI\\4BCDEF.HI\\5BCDEF.HI\\6BCDEF.HI\\",  TRUE,  TRUE,  FALSE, TRUE,  FALSE },
97     { "0BCDEF.HI\\1BCDEF.HI\\2BCDEF.HI\\3BCDEF.HI\\4BCDEF.HI\\5BCDEF.HI\\6BCDEF.HI\\7BCDEF.HI\\8BCDEF.HI\\9BCDEF.HI\\0BCDEF.HI\\1BCDEF.HI\\2BCDEF.HI\\3BCDEF.HI\\4BCDEF.HI\\5BCDEF.HI\\6BCDEF.HI\\7BCDEF.HI\\8BCDEF.HI\\9BCDEF.HI\\0BCDEF.HI\\1BCDEF.HI\\2BCDEF.HI\\3BCDEF.HI\\4BCDEF.HI\\5BCDEF.HI\\6BCDEF.HI\\7", TRUE,  TRUE,  FALSE, TRUE,  FALSE },
98     /* Max component length for HPFS is 255 characters */
99     { "ABCDEFGHI1ABCDEFGHI2ABCDEFGHI3ABCDEFGHI4ABCDEFGHI5ABCDEFGHI6ABCDEFGHI7ABCDEFGHI8ABCDEFGHI9ABCDEFGHI0ABCDEFGHI1ABCDEFGHI2ABCDEFGHI3ABCDEFGHI4ABCDEFGHI5ABCDEFGHI6ABCDEFGHI7ABCDEFGHI8ABCDEFGHI9ABCDEFGHI0ABCDEFGHI1ABCDEFGHI2ABCDEFGHI3ABCDEFGHI4ABCDEFGHI5ABCDE",                                            FALSE, TRUE,  FALSE, FALSE, FALSE },
100     { "ABCDEFGHI1ABCDEFGHI2ABCDEFGHI3ABCDEFGHI4ABCDEFGHI5ABCDEFGHI6ABCDEFGHI7ABCDEFGHI8ABCDEFGHI9ABCDEFGHI0ABCDEFGHI1ABCDEFGHI2ABCDEFGHI3ABCDEFGHI4ABCDEFGHI5ABCDEFGHI6ABCDEFGHI7ABCDEFGHI8ABCDEFGHI9ABCDEFGHI0ABCDEFGHI1ABCDEFGHI2ABCDEFGHI3ABCDEFGHI4ABCDEFGHI5ABCDEF",                                           FALSE, FALSE                      },
101     { "ABCDEFGHI1ABCDEFGHI2ABCDEFGHI3ABCDEFGHI4ABCDEFGHI5ABCDEFGHI6ABCDEFGHI7ABCDEFGHI8ABCDEFGHI9ABCDEFGHI0ABCDEFGHI1ABCDEFGHI2ABCDEFGHI3ABCDEFGHI4ABCDEFGHI5ABCDEFGHI6ABCDEFGHI7ABCDEFGHI8ABCDEFGHI9ABCDEFGHI0ABCDEFGHI1ABCDEFGHI2ABCDEFGHI3ABCDEFGHI4ABCDEFGHI5ABCDE\\ABC",                                       FALSE, TRUE,  FALSE, TRUE,  FALSE },
102 };
103 
104 static const UCHAR LegalAnsiCharacterArray[] =
105 {
106   0,                                                                          /* CTRL+@, 0x00 */
107   FSRTL_OLE_LEGAL,                                                            /* CTRL+A, 0x01 */
108   FSRTL_OLE_LEGAL,                                                            /* CTRL+B, 0x02 */
109   FSRTL_OLE_LEGAL,                                                            /* CTRL+C, 0x03 */
110   FSRTL_OLE_LEGAL,                                                            /* CTRL+D, 0x04 */
111   FSRTL_OLE_LEGAL,                                                            /* CTRL+E, 0x05 */
112   FSRTL_OLE_LEGAL,                                                            /* CTRL+F, 0x06 */
113   FSRTL_OLE_LEGAL,                                                            /* CTRL+G, 0x07 */
114   FSRTL_OLE_LEGAL,                                                            /* CTRL+H, 0x08 */
115   FSRTL_OLE_LEGAL,                                                            /* CTRL+I, 0x09 */
116   FSRTL_OLE_LEGAL,                                                            /* CTRL+J, 0x0a */
117   FSRTL_OLE_LEGAL,                                                            /* CTRL+K, 0x0b */
118   FSRTL_OLE_LEGAL,                                                            /* CTRL+L, 0x0c */
119   FSRTL_OLE_LEGAL,                                                            /* CTRL+M, 0x0d */
120   FSRTL_OLE_LEGAL,                                                            /* CTRL+N, 0x0e */
121   FSRTL_OLE_LEGAL,                                                            /* CTRL+O, 0x0f */
122   FSRTL_OLE_LEGAL,                                                            /* CTRL+P, 0x10 */
123   FSRTL_OLE_LEGAL,                                                            /* CTRL+Q, 0x11 */
124   FSRTL_OLE_LEGAL,                                                            /* CTRL+R, 0x12 */
125   FSRTL_OLE_LEGAL,                                                            /* CTRL+S, 0x13 */
126   FSRTL_OLE_LEGAL,                                                            /* CTRL+T, 0x14 */
127   FSRTL_OLE_LEGAL,                                                            /* CTRL+U, 0x15 */
128   FSRTL_OLE_LEGAL,                                                            /* CTRL+V, 0x16 */
129   FSRTL_OLE_LEGAL,                                                            /* CTRL+W, 0x17 */
130   FSRTL_OLE_LEGAL,                                                            /* CTRL+X, 0x18 */
131   FSRTL_OLE_LEGAL,                                                            /* CTRL+Y, 0x19 */
132   FSRTL_OLE_LEGAL,                                                            /* CTRL+Z, 0x1a */
133   FSRTL_OLE_LEGAL,                                                            /* CTRL+[, 0x1b */
134   FSRTL_OLE_LEGAL,                                                            /* CTRL+\, 0x1c */
135   FSRTL_OLE_LEGAL,                                                            /* CTRL+], 0x1d */
136   FSRTL_OLE_LEGAL,                                                            /* CTRL+^, 0x1e */
137   FSRTL_OLE_LEGAL,                                                            /* CTRL+_, 0x1f */
138   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* ` ',    0x20 */
139   FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,                      /* `!',    0x21 */
140   FSRTL_OLE_LEGAL | FSRTL_WILD_CHARACTER,                                     /* `"',    0x22 */
141   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `#',    0x23 */
142   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `$',    0x24 */
143   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `%',    0x25 */
144   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `&',    0x26 */
145   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `'',    0x27 */
146   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `(',    0x28 */
147   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `)',    0x29 */
148   FSRTL_OLE_LEGAL | FSRTL_WILD_CHARACTER,                                     /* `*',    0x2a */
149   FSRTL_OLE_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,                      /* `+',    0x2b */
150   FSRTL_OLE_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,                      /* `,',    0x2c */
151   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `-',    0x2d */
152   FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,                      /* `.',    0x2e */
153   0,                                                                          /* `/',    0x2f */
154   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `0',    0x30 */
155   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `1',    0x31 */
156   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `2',    0x32 */
157   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `3',    0x33 */
158   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `4',    0x34 */
159   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `5',    0x35 */
160   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `6',    0x36 */
161   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `7',    0x37 */
162   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `8',    0x38 */
163   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `9',    0x39 */
164   FSRTL_NTFS_LEGAL,                                                           /* `:',    0x3a */
165   FSRTL_OLE_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,                      /* `;',    0x3b */
166   FSRTL_OLE_LEGAL | FSRTL_WILD_CHARACTER,                                     /* `<',    0x3c */
167   FSRTL_OLE_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,                      /* `=',    0x3d */
168   FSRTL_OLE_LEGAL | FSRTL_WILD_CHARACTER,                                     /* `>',    0x3e */
169   FSRTL_OLE_LEGAL | FSRTL_WILD_CHARACTER,                                     /* `?',    0x3f */
170   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `@',    0x40 */
171   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `A',    0x41 */
172   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `B',    0x42 */
173   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `C',    0x43 */
174   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `D',    0x44 */
175   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `E',    0x45 */
176   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `F',    0x46 */
177   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `G',    0x47 */
178   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `H',    0x48 */
179   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `I',    0x49 */
180   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `J',    0x4a */
181   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `K',    0x4b */
182   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `L',    0x4c */
183   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `M',    0x4d */
184   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `N',    0x4e */
185   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `O',    0x4f */
186   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `P',    0x50 */
187   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `Q',    0x51 */
188   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `R',    0x52 */
189   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `S',    0x53 */
190   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `T',    0x54 */
191   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `U',    0x55 */
192   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `V',    0x56 */
193   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `W',    0x57 */
194   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `X',    0x58 */
195   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `Y',    0x59 */
196   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `Z',    0x5a */
197   FSRTL_OLE_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,                      /* `[',    0x5b */
198   0,                                                                          /* `\',    0x5c */
199   FSRTL_OLE_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,                      /* `]',    0x5d */
200   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `^',    0x5e */
201   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `_',    0x5f */
202   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* ``',    0x60 */
203   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `a',    0x61 */
204   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `b',    0x62 */
205   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `c',    0x63 */
206   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `d',    0x64 */
207   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `e',    0x65 */
208   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `f',    0x66 */
209   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `g',    0x67 */
210   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `h',    0x68 */
211   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `i',    0x69 */
212   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `j',    0x6a */
213   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `k',    0x6b */
214   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `l',    0x6c */
215   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `m',    0x6d */
216   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `n',    0x6e */
217   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `o',    0x6f */
218   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `p',    0x70 */
219   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `q',    0x71 */
220   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `r',    0x72 */
221   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `s',    0x73 */
222   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `t',    0x74 */
223   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `u',    0x75 */
224   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `v',    0x76 */
225   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `w',    0x77 */
226   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `x',    0x78 */
227   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `y',    0x79 */
228   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `z',    0x7a */
229   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `{',    0x7b */
230   FSRTL_OLE_LEGAL,                                                            /* `|',    0x7c */
231   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `}',    0x7d */
232   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL,    /* `~',    0x7e */
233   FSRTL_OLE_LEGAL | FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL     /*         0x7f */
234 };
235 
236 START_TEST(FsRtlLegal)
237 {
238     ULONG i;
239     BOOLEAN Result;
240     ANSI_STRING DbcsName;
241     ULONG Flags;
242 
243     for (i = 0; i < RTL_NUMBER_OF(NamesTests); i++)
244     {
245         RtlInitAnsiString(&DbcsName, NamesTests[i].Dbcs);
246         for (Flags = 0; Flags < 8; Flags++)
247         {
248             Result = FsRtlIsFatDbcsLegal(DbcsName,
249                                          BooleanFlagOn(Flags, 1),
250                                          BooleanFlagOn(Flags, 2),
251                                          BooleanFlagOn(Flags, 4));
252             if (NamesTests[i].HasWildCards && !FlagOn(Flags, 1))
253                 ok(Result == FALSE, "[%s] Result = %u but has wildcards\n", NamesTests[i].Dbcs, Result);
254             else if (NamesTests[i].IsPath && !FlagOn(Flags, 2))
255                 ok(Result == FALSE, "[%s] Result = %u but is path\n", NamesTests[i].Dbcs, Result);
256             else if (NamesTests[i].LeadingBackslash && !FlagOn(Flags, 4))
257                 ok(Result == FALSE, "[%s] Result = %u but has leading backslash\n", NamesTests[i].Dbcs, Result);
258             else if (!NamesTests[i].LegalFat)
259                 ok(Result == FALSE, "[%s] Result = %u but is NOT legal FAT\n", NamesTests[i].Dbcs, Result);
260             else
261                 ok(Result == TRUE, "[%s] Result = %u but IS legal FAT\n", NamesTests[i].Dbcs, Result);
262 
263             Result = FsRtlIsHpfsDbcsLegal(DbcsName,
264                                           BooleanFlagOn(Flags, 1),
265                                           BooleanFlagOn(Flags, 2),
266                                           BooleanFlagOn(Flags, 4));
267             if (NamesTests[i].HasWildCards && !FlagOn(Flags, 1))
268                 ok(Result == FALSE, "[%s] Result = %u but has wildcards\n", NamesTests[i].Dbcs, Result);
269             else if (NamesTests[i].IsPath && !FlagOn(Flags, 2))
270                 ok(Result == FALSE, "[%s] Result = %u but is path\n", NamesTests[i].Dbcs, Result);
271             else if (NamesTests[i].LeadingBackslash && !FlagOn(Flags, 4))
272                 ok(Result == FALSE, "[%s] Result = %u but has leading backslash\n", NamesTests[i].Dbcs, Result);
273             else if (!NamesTests[i].LegalHpfs)
274                 ok(Result == FALSE, "[%s] Result = %u but is NOT legal HPFS\n", NamesTests[i].Dbcs, Result);
275             else
276                 ok(Result == TRUE, "[%s] Result = %u but IS legal HPFS\n", NamesTests[i].Dbcs, Result);
277         }
278     }
279 
280     for (i = 0; i <= 0x7f; ++i)
281     {
282         ok(LegalAnsiCharacterArray[i] == (*FsRtlLegalAnsiCharacterArray)[i],
283            "Mismatching value for 0x%x: 0x%x (exp) - 0x%x (got)\n", i, LegalAnsiCharacterArray[i], (*FsRtlLegalAnsiCharacterArray)[i]);
284 
285         ok((FsRtlIsAnsiCharacterWild(i) != 0) == BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_WILD_CHARACTER),
286            "Mismatching value for 0x%x: 0x%x (exp) - 0x%x (got)\n", i, FsRtlIsAnsiCharacterWild(i), BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_WILD_CHARACTER));
287 
288         ok((FsRtlIsAnsiCharacterLegalFat(i, FALSE) != 0) == BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_FAT_LEGAL),
289            "Mismatching value for 0x%x: 0x%x (exp) - 0x%x (got)\n", i, FsRtlIsAnsiCharacterLegalFat(i, FALSE), BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_FAT_LEGAL));
290         ok((FsRtlIsAnsiCharacterLegalFat(i, TRUE) != 0) == (BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_FAT_LEGAL) || BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_WILD_CHARACTER)),
291            "Mismatching value for 0x%x: 0x%x (exp) - 0x%x (got)\n", i, FsRtlIsAnsiCharacterLegalFat(i, TRUE),
292                                                                     (BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_FAT_LEGAL) || BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_WILD_CHARACTER)));
293 
294         ok((FsRtlIsAnsiCharacterLegalHpfs(i, FALSE) != 0) == BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_HPFS_LEGAL),
295            "Mismatching value for 0x%x: 0x%x (exp) - 0x%x (got)\n", i, FsRtlIsAnsiCharacterLegalHpfs(i, FALSE), BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_HPFS_LEGAL));
296         ok((FsRtlIsAnsiCharacterLegalHpfs(i, TRUE) != 0) == (BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_HPFS_LEGAL) || BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_WILD_CHARACTER)),
297            "Mismatching value for 0x%x: 0x%x (exp) - 0x%x (got)\n", i, FsRtlIsAnsiCharacterLegalHpfs(i, TRUE),
298                                                                     (BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_HPFS_LEGAL) || BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_WILD_CHARACTER)));
299 
300         ok((FsRtlIsAnsiCharacterLegalNtfs(i, FALSE) != 0) == BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_NTFS_LEGAL),
301            "Mismatching value for 0x%x: 0x%x (exp) - 0x%x (got)\n", i, FsRtlIsAnsiCharacterLegalNtfs(i, FALSE), BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_NTFS_LEGAL));
302         ok((FsRtlIsAnsiCharacterLegalNtfs(i, TRUE) != 0) == (BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_NTFS_LEGAL) || BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_WILD_CHARACTER)),
303            "Mismatching value for 0x%x: 0x%x (exp) - 0x%x (got)\n", i, FsRtlIsAnsiCharacterLegalNtfs(i, TRUE),
304                                                                     (BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_NTFS_LEGAL) || BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_WILD_CHARACTER)));
305 
306         ok((FsRtlIsAnsiCharacterLegalNtfsStream(i, FALSE) != 0) == BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_NTFS_STREAM_LEGAL),
307            "Mismatching value for 0x%x: 0x%x (exp) - 0x%x (got)\n", i, FsRtlIsAnsiCharacterLegalNtfsStream(i, FALSE), BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_NTFS_STREAM_LEGAL));
308         ok((FsRtlIsAnsiCharacterLegalNtfsStream(i, TRUE) !=0 ) == (BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_NTFS_STREAM_LEGAL) || BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_WILD_CHARACTER)),
309            "Mismatching value for 0x%x: 0x%x (exp) - 0x%x (got)\n", i, FsRtlIsAnsiCharacterLegalNtfsStream(i, TRUE),
310                                                                     (BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_NTFS_STREAM_LEGAL) || BooleanFlagOn(LegalAnsiCharacterArray[i], FSRTL_WILD_CHARACTER)));
311     }
312 }
313