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>
10 #define WIN32_NO_STATUS
11 #include <ndk/mmfuncs.h>
12 #include <ndk/rtlfuncs.h>
17 RtlDetermineDosPathNameType_U(
23 RtlDetermineDosPathNameType_Ustr(
24 IN PCUNICODE_STRING Path
31 *RtlDetermineDosPathNameType_Ustr
)(
32 IN PCUNICODE_STRING Path
34 //= (PVOID)0x7c830669;
43 SIZE_T Size
= PAGE_ROUND_UP(SizeRequested
+ PAGE_SIZE
);
44 PVOID VirtualMemory
= NULL
;
47 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory
, 0, &Size
, MEM_RESERVE
, PAGE_NOACCESS
);
49 if (!NT_SUCCESS(Status
))
55 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory
, 0, &Size
, MEM_COMMIT
, PAGE_READWRITE
);
56 if (!NT_SUCCESS(Status
))
59 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory
, &Size
, MEM_RELEASE
);
60 ok(Status
== STATUS_SUCCESS
, "Status = %lx\n", Status
);
65 StartOfBuffer
= VirtualMemory
;
66 StartOfBuffer
+= Size
- SizeRequested
;
78 SIZE_T Size
= PAGE_ROUND_UP(SizeRequested
);
79 PVOID VirtualMemory
= (PVOID
)PAGE_ROUND_DOWN((SIZE_T
)Pointer
);
83 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory
, 0, &Size
, MEM_COMMIT
, PAGE_READWRITE
);
84 if (!NT_SUCCESS(Status
))
87 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory
, &Size
, MEM_RELEASE
);
88 ok(Status
== STATUS_SUCCESS
, "Status = %lx\n", Status
);
99 PVOID VirtualMemory
= (PVOID
)PAGE_ROUND_DOWN((SIZE_T
)Pointer
);
102 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory
, &Size
, MEM_RELEASE
);
103 ok(Status
== STATUS_SUCCESS
, "Status = %lx\n", Status
);
106 START_TEST(RtlDetermineDosPathNameType
)
108 RTL_PATH_TYPE PathType
;
112 RTL_PATH_TYPE PathType
;
115 { L
"", RtlPathTypeRelative
},
116 { L
"xyz", RtlPathTypeRelative
},
117 { L
"CON", RtlPathTypeRelative
},
118 { L
"NUL", RtlPathTypeRelative
},
119 { L
":", RtlPathTypeRelative
},
120 { L
"::", RtlPathTypeDriveRelative
},
121 { L
":::", RtlPathTypeDriveRelative
},
122 { L
"::::", RtlPathTypeDriveRelative
},
123 { L
"::\\", RtlPathTypeDriveAbsolute
},
124 { L
"\\", RtlPathTypeRooted
},
125 { L
"\\:", RtlPathTypeRooted
},
126 { L
"\\C:", RtlPathTypeRooted
},
127 { L
"\\C:\\", RtlPathTypeRooted
},
128 { L
"/", RtlPathTypeRooted
},
129 { L
"/:", RtlPathTypeRooted
},
130 { L
"/C:", RtlPathTypeRooted
},
131 { L
"/C:/", RtlPathTypeRooted
},
132 { L
"C", RtlPathTypeRelative
},
133 { L
"C:", RtlPathTypeDriveRelative
},
134 { L
"C:a", RtlPathTypeDriveRelative
},
135 { L
"C:a\\", RtlPathTypeDriveRelative
},
136 { L
"C:\\", RtlPathTypeDriveAbsolute
},
137 { L
"C:/", RtlPathTypeDriveAbsolute
},
138 { L
"C:\\a", RtlPathTypeDriveAbsolute
},
139 { L
"C:/a", RtlPathTypeDriveAbsolute
},
140 { L
"C:\\\\", RtlPathTypeDriveAbsolute
},
141 { L
"\\\\", RtlPathTypeUncAbsolute
},
142 { L
"\\\\\\", RtlPathTypeUncAbsolute
},
143 { L
"\\\\;", RtlPathTypeUncAbsolute
},
144 { L
"\\\\f\\b\\", RtlPathTypeUncAbsolute
},
145 { L
"\\\\f\\b", RtlPathTypeUncAbsolute
},
146 { L
"\\\\f\\", RtlPathTypeUncAbsolute
},
147 { L
"\\\\f", RtlPathTypeUncAbsolute
},
148 { L
"\\??\\", RtlPathTypeRooted
},
149 { L
"\\??\\UNC", RtlPathTypeRooted
},
150 { L
"\\??\\UNC\\", RtlPathTypeRooted
},
151 { L
"\\?", RtlPathTypeRooted
},
152 { L
"\\?\\", RtlPathTypeRooted
},
153 { L
"\\?\\UNC", RtlPathTypeRooted
},
154 { L
"\\?\\UNC\\", RtlPathTypeRooted
},
155 { L
"\\\\?\\UNC\\", RtlPathTypeLocalDevice
},
156 { L
"\\\\?", RtlPathTypeRootLocalDevice
},
157 { L
"\\\\??", RtlPathTypeUncAbsolute
},
158 { L
"\\\\??\\", RtlPathTypeUncAbsolute
},
159 { L
"\\\\??\\C:\\", RtlPathTypeUncAbsolute
},
160 { L
"\\\\.", RtlPathTypeRootLocalDevice
},
161 { L
"\\\\.\\", RtlPathTypeLocalDevice
},
162 { L
"\\\\.\\C:\\", RtlPathTypeLocalDevice
},
163 { L
"\\/", RtlPathTypeUncAbsolute
},
164 { L
"/\\", RtlPathTypeUncAbsolute
},
165 { L
"//", RtlPathTypeUncAbsolute
},
166 { L
"///", RtlPathTypeUncAbsolute
},
167 { L
"//;", RtlPathTypeUncAbsolute
},
168 { L
"//?", RtlPathTypeRootLocalDevice
},
169 { L
"/\\?", RtlPathTypeRootLocalDevice
},
170 { L
"\\/?", RtlPathTypeRootLocalDevice
},
171 { L
"//??", RtlPathTypeUncAbsolute
},
172 { L
"//?" L
"?/", RtlPathTypeUncAbsolute
},
173 { L
"//?" L
"?/C:/", RtlPathTypeUncAbsolute
},
174 { L
"//.", RtlPathTypeRootLocalDevice
},
175 { L
"\\/.", RtlPathTypeRootLocalDevice
},
176 { L
"/\\.", RtlPathTypeRootLocalDevice
},
177 { L
"//./", RtlPathTypeLocalDevice
},
178 { L
"//./C:/", RtlPathTypeLocalDevice
},
179 { L
"%SystemRoot%", RtlPathTypeRelative
},
185 if (!RtlDetermineDosPathNameType_Ustr
)
187 RtlDetermineDosPathNameType_Ustr
= (PVOID
)GetProcAddress(GetModuleHandleW(L
"ntdll"), "RtlDetermineDosPathNameType_Ustr");
188 if (!RtlDetermineDosPathNameType_Ustr
)
189 skip("RtlDetermineDosPathNameType_Ustr unavailable\n");
192 StartSeh() RtlDetermineDosPathNameType_U(NULL
); EndSeh(STATUS_ACCESS_VIOLATION
);
194 if (RtlDetermineDosPathNameType_Ustr
)
196 UNICODE_STRING PathString
;
197 StartSeh() RtlDetermineDosPathNameType_Ustr(NULL
); EndSeh(STATUS_ACCESS_VIOLATION
);
199 RtlInitEmptyUnicodeString(&PathString
, NULL
, MAXUSHORT
);
200 PathType
= RtlDetermineDosPathNameType_Ustr(&PathString
);
201 ok(PathType
== RtlPathTypeRelative
, "PathType = %d\n", PathType
);
204 for (i
= 0; i
< sizeof(Tests
) / sizeof(Tests
[0]); i
++)
206 Length
= (USHORT
)wcslen(Tests
[i
].FileName
) * sizeof(WCHAR
);
207 FileName
= AllocateGuarded(Length
+ sizeof(UNICODE_NULL
));
208 RtlCopyMemory(FileName
, Tests
[i
].FileName
, Length
+ sizeof(UNICODE_NULL
));
209 MakeReadOnly(FileName
, Length
+ sizeof(UNICODE_NULL
));
211 PathType
= RtlDetermineDosPathNameType_U(FileName
);
212 ok(PathType
== Tests
[i
].PathType
, "PathType is %d, expected %d for '%S'\n", PathType
, Tests
[i
].PathType
, Tests
[i
].FileName
);
213 EndSeh(STATUS_SUCCESS
);
214 FreeGuarded(FileName
);
216 if (RtlDetermineDosPathNameType_Ustr
)
218 UNICODE_STRING PathString
;
220 FileName
= AllocateGuarded(Length
);
221 RtlCopyMemory(FileName
, Tests
[i
].FileName
, Length
);
222 MakeReadOnly(FileName
, Length
);
223 PathString
.Buffer
= FileName
;
224 PathString
.Length
= Length
;
225 PathString
.MaximumLength
= MAXUSHORT
;
227 PathType
= RtlDetermineDosPathNameType_Ustr(&PathString
);
228 ok(PathType
== Tests
[i
].PathType
, "PathType is %d, expected %d for '%S'\n", PathType
, Tests
[i
].PathType
, Tests
[i
].FileName
);
229 EndSeh(STATUS_SUCCESS
);
230 FreeGuarded(FileName
);