2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for RtlDetermineDosPathNameType_U/RtlDetermineDosPathNameType_Ustr
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
13 RtlDetermineDosPathNameType_U(
19 RtlDetermineDosPathNameType_Ustr(
20 IN PCUNICODE_STRING Path
27 *RtlDetermineDosPathNameType_Ustr
)(
28 IN PCUNICODE_STRING Path
30 //= (PVOID)0x7c830669;
39 SIZE_T Size
= PAGE_ROUND_UP(SizeRequested
+ PAGE_SIZE
);
40 PVOID VirtualMemory
= NULL
;
43 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory
, 0, &Size
, MEM_RESERVE
, PAGE_NOACCESS
);
45 if (!NT_SUCCESS(Status
))
51 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory
, 0, &Size
, MEM_COMMIT
, PAGE_READWRITE
);
52 if (!NT_SUCCESS(Status
))
55 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory
, &Size
, MEM_RELEASE
);
56 ok(Status
== STATUS_SUCCESS
, "Status = %lx\n", Status
);
61 StartOfBuffer
= VirtualMemory
;
62 StartOfBuffer
+= Size
- SizeRequested
;
74 SIZE_T Size
= PAGE_ROUND_UP(SizeRequested
);
75 PVOID VirtualMemory
= (PVOID
)PAGE_ROUND_DOWN((SIZE_T
)Pointer
);
79 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory
, 0, &Size
, MEM_COMMIT
, PAGE_READWRITE
);
80 if (!NT_SUCCESS(Status
))
83 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory
, &Size
, MEM_RELEASE
);
84 ok(Status
== STATUS_SUCCESS
, "Status = %lx\n", Status
);
95 PVOID VirtualMemory
= (PVOID
)PAGE_ROUND_DOWN((SIZE_T
)Pointer
);
98 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory
, &Size
, MEM_RELEASE
);
99 ok(Status
== STATUS_SUCCESS
, "Status = %lx\n", Status
);
102 START_TEST(RtlDetermineDosPathNameType
)
104 RTL_PATH_TYPE PathType
;
108 RTL_PATH_TYPE PathType
;
111 { L
"", RtlPathTypeRelative
},
112 { L
"xyz", RtlPathTypeRelative
},
113 { L
"CON", RtlPathTypeRelative
},
114 { L
"NUL", RtlPathTypeRelative
},
115 { L
":", RtlPathTypeRelative
},
116 { L
"::", RtlPathTypeDriveRelative
},
117 { L
":::", RtlPathTypeDriveRelative
},
118 { L
"::::", RtlPathTypeDriveRelative
},
119 { L
"::\\", RtlPathTypeDriveAbsolute
},
120 { L
"\\", RtlPathTypeRooted
},
121 { L
"\\:", RtlPathTypeRooted
},
122 { L
"\\C:", RtlPathTypeRooted
},
123 { L
"\\C:\\", RtlPathTypeRooted
},
124 { L
"/", RtlPathTypeRooted
},
125 { L
"/:", RtlPathTypeRooted
},
126 { L
"/C:", RtlPathTypeRooted
},
127 { L
"/C:/", RtlPathTypeRooted
},
128 { L
"C", RtlPathTypeRelative
},
129 { L
"C:", RtlPathTypeDriveRelative
},
130 { L
"C:a", RtlPathTypeDriveRelative
},
131 { L
"C:a\\", RtlPathTypeDriveRelative
},
132 { L
"C:\\", RtlPathTypeDriveAbsolute
},
133 { L
"C:/", RtlPathTypeDriveAbsolute
},
134 { L
"C:\\a", RtlPathTypeDriveAbsolute
},
135 { L
"C:/a", RtlPathTypeDriveAbsolute
},
136 { L
"C:\\\\", RtlPathTypeDriveAbsolute
},
137 { L
"\\\\", RtlPathTypeUncAbsolute
},
138 { L
"\\\\\\", RtlPathTypeUncAbsolute
},
139 { L
"\\\\;", RtlPathTypeUncAbsolute
},
140 { L
"\\\\f\\b\\", RtlPathTypeUncAbsolute
},
141 { L
"\\\\f\\b", RtlPathTypeUncAbsolute
},
142 { L
"\\\\f\\", RtlPathTypeUncAbsolute
},
143 { L
"\\\\f", RtlPathTypeUncAbsolute
},
144 { L
"\\??\\", RtlPathTypeRooted
},
145 { L
"\\??\\UNC", RtlPathTypeRooted
},
146 { L
"\\??\\UNC\\", RtlPathTypeRooted
},
147 { L
"\\?", RtlPathTypeRooted
},
148 { L
"\\?\\", RtlPathTypeRooted
},
149 { L
"\\?\\UNC", RtlPathTypeRooted
},
150 { L
"\\?\\UNC\\", RtlPathTypeRooted
},
151 { L
"\\\\?\\UNC\\", RtlPathTypeLocalDevice
},
152 { L
"\\\\?", RtlPathTypeRootLocalDevice
},
153 { L
"\\\\??", RtlPathTypeUncAbsolute
},
154 { L
"\\\\??\\", RtlPathTypeUncAbsolute
},
155 { L
"\\\\??\\C:\\", RtlPathTypeUncAbsolute
},
156 { L
"\\\\.", RtlPathTypeRootLocalDevice
},
157 { L
"\\\\.\\", RtlPathTypeLocalDevice
},
158 { L
"\\\\.\\C:\\", RtlPathTypeLocalDevice
},
159 { L
"\\/", RtlPathTypeUncAbsolute
},
160 { L
"/\\", RtlPathTypeUncAbsolute
},
161 { L
"//", RtlPathTypeUncAbsolute
},
162 { L
"///", RtlPathTypeUncAbsolute
},
163 { L
"//;", RtlPathTypeUncAbsolute
},
164 { L
"//?", RtlPathTypeRootLocalDevice
},
165 { L
"/\\?", RtlPathTypeRootLocalDevice
},
166 { L
"\\/?", RtlPathTypeRootLocalDevice
},
167 { L
"//??", RtlPathTypeUncAbsolute
},
168 { L
"//?" L
"?/", RtlPathTypeUncAbsolute
},
169 { L
"//?" L
"?/C:/", RtlPathTypeUncAbsolute
},
170 { L
"//.", RtlPathTypeRootLocalDevice
},
171 { L
"\\/.", RtlPathTypeRootLocalDevice
},
172 { L
"/\\.", RtlPathTypeRootLocalDevice
},
173 { L
"//./", RtlPathTypeLocalDevice
},
174 { L
"//./C:/", RtlPathTypeLocalDevice
},
175 { L
"%SystemRoot%", RtlPathTypeRelative
},
181 if (!RtlDetermineDosPathNameType_Ustr
)
183 RtlDetermineDosPathNameType_Ustr
= (PVOID
)GetProcAddress(GetModuleHandleW(L
"ntdll"), "RtlDetermineDosPathNameType_Ustr");
184 if (!RtlDetermineDosPathNameType_Ustr
)
185 skip("RtlDetermineDosPathNameType_Ustr unavailable\n");
188 StartSeh() RtlDetermineDosPathNameType_U(NULL
); EndSeh(STATUS_ACCESS_VIOLATION
);
190 if (RtlDetermineDosPathNameType_Ustr
)
192 UNICODE_STRING PathString
;
193 StartSeh() RtlDetermineDosPathNameType_Ustr(NULL
); EndSeh(STATUS_ACCESS_VIOLATION
);
195 RtlInitEmptyUnicodeString(&PathString
, NULL
, MAXUSHORT
);
196 PathType
= RtlDetermineDosPathNameType_Ustr(&PathString
);
197 ok(PathType
== RtlPathTypeRelative
, "PathType = %d\n", PathType
);
200 for (i
= 0; i
< sizeof(Tests
) / sizeof(Tests
[0]); i
++)
202 Length
= (USHORT
)wcslen(Tests
[i
].FileName
) * sizeof(WCHAR
);
203 FileName
= AllocateGuarded(Length
+ sizeof(UNICODE_NULL
));
204 RtlCopyMemory(FileName
, Tests
[i
].FileName
, Length
+ sizeof(UNICODE_NULL
));
205 MakeReadOnly(FileName
, Length
+ sizeof(UNICODE_NULL
));
207 PathType
= RtlDetermineDosPathNameType_U(FileName
);
208 ok(PathType
== Tests
[i
].PathType
, "PathType is %d, expected %d for '%S'\n", PathType
, Tests
[i
].PathType
, Tests
[i
].FileName
);
209 EndSeh(STATUS_SUCCESS
);
210 FreeGuarded(FileName
);
212 if (RtlDetermineDosPathNameType_Ustr
)
214 UNICODE_STRING PathString
;
216 FileName
= AllocateGuarded(Length
);
217 RtlCopyMemory(FileName
, Tests
[i
].FileName
, Length
);
218 MakeReadOnly(FileName
, Length
);
219 PathString
.Buffer
= FileName
;
220 PathString
.Length
= Length
;
221 PathString
.MaximumLength
= MAXUSHORT
;
223 PathType
= RtlDetermineDosPathNameType_Ustr(&PathString
);
224 ok(PathType
== Tests
[i
].PathType
, "PathType is %d, expected %d for '%S'\n", PathType
, Tests
[i
].PathType
, Tests
[i
].FileName
);
225 EndSeh(STATUS_SUCCESS
);
226 FreeGuarded(FileName
);