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 <thfabba@gmx.de>
8 #define WIN32_NO_STATUS
10 #include <wine/test.h>
11 #include <pseh/pseh2.h>
12 #include <ndk/mmfuncs.h>
13 #include <ndk/rtlfuncs.h>
18 RtlDetermineDosPathNameType_U(
24 RtlDetermineDosPathNameType_Ustr(
25 IN PCUNICODE_STRING Path
32 *RtlDetermineDosPathNameType_Ustr
)(
33 IN PCUNICODE_STRING Path
35 //= (PVOID)0x7c830669;
44 SIZE_T Size
= PAGE_ROUND_UP(SizeRequested
+ PAGE_SIZE
);
45 PVOID VirtualMemory
= NULL
;
48 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory
, 0, &Size
, MEM_RESERVE
, PAGE_NOACCESS
);
50 if (!NT_SUCCESS(Status
))
56 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory
, 0, &Size
, MEM_COMMIT
, PAGE_READWRITE
);
57 if (!NT_SUCCESS(Status
))
60 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory
, &Size
, MEM_RELEASE
);
61 ok(Status
== STATUS_SUCCESS
, "Status = %lx\n", Status
);
66 StartOfBuffer
= VirtualMemory
;
67 StartOfBuffer
+= Size
- SizeRequested
;
79 SIZE_T Size
= PAGE_ROUND_UP(SizeRequested
);
80 PVOID VirtualMemory
= (PVOID
)PAGE_ROUND_DOWN((SIZE_T
)Pointer
);
84 Status
= NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory
, 0, &Size
, MEM_COMMIT
, PAGE_READWRITE
);
85 if (!NT_SUCCESS(Status
))
88 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory
, &Size
, MEM_RELEASE
);
89 ok(Status
== STATUS_SUCCESS
, "Status = %lx\n", Status
);
100 PVOID VirtualMemory
= (PVOID
)PAGE_ROUND_DOWN((SIZE_T
)Pointer
);
103 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory
, &Size
, MEM_RELEASE
);
104 ok(Status
== STATUS_SUCCESS
, "Status = %lx\n", Status
);
107 #define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY {
108 #define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus)
110 START_TEST(RtlDetermineDosPathNameType
)
112 NTSTATUS ExceptionStatus
;
113 RTL_PATH_TYPE PathType
;
117 RTL_PATH_TYPE PathType
;
120 { L
"", RtlPathTypeRelative
},
121 { L
"xyz", RtlPathTypeRelative
},
122 { L
"CON", RtlPathTypeRelative
},
123 { L
"NUL", RtlPathTypeRelative
},
124 { L
":", RtlPathTypeRelative
},
125 { L
"::", RtlPathTypeDriveRelative
},
126 { L
":::", RtlPathTypeDriveRelative
},
127 { L
"::::", RtlPathTypeDriveRelative
},
128 { L
"::\\", RtlPathTypeDriveAbsolute
},
129 { L
"\\", RtlPathTypeRooted
},
130 { L
"\\:", RtlPathTypeRooted
},
131 { L
"\\C:", RtlPathTypeRooted
},
132 { L
"\\C:\\", RtlPathTypeRooted
},
133 { L
"/", RtlPathTypeRooted
},
134 { L
"/:", RtlPathTypeRooted
},
135 { L
"/C:", RtlPathTypeRooted
},
136 { L
"/C:/", RtlPathTypeRooted
},
137 { L
"C", RtlPathTypeRelative
},
138 { L
"C:", RtlPathTypeDriveRelative
},
139 { L
"C:a", RtlPathTypeDriveRelative
},
140 { L
"C:a\\", RtlPathTypeDriveRelative
},
141 { L
"C:\\", RtlPathTypeDriveAbsolute
},
142 { L
"C:/", RtlPathTypeDriveAbsolute
},
143 { L
"C:\\a", RtlPathTypeDriveAbsolute
},
144 { L
"C:/a", RtlPathTypeDriveAbsolute
},
145 { L
"C:\\\\", RtlPathTypeDriveAbsolute
},
146 { L
"\\\\", RtlPathTypeUncAbsolute
},
147 { L
"\\\\\\", RtlPathTypeUncAbsolute
},
148 { L
"\\\\;", RtlPathTypeUncAbsolute
},
149 { L
"\\??\\", RtlPathTypeRooted
},
150 { L
"\\??\\UNC", RtlPathTypeRooted
},
151 { L
"\\??\\UNC\\", RtlPathTypeRooted
},
152 { L
"\\?", RtlPathTypeRooted
},
153 { L
"\\?\\", RtlPathTypeRooted
},
154 { L
"\\?\\UNC", RtlPathTypeRooted
},
155 { L
"\\?\\UNC\\", RtlPathTypeRooted
},
156 { L
"\\\\?\\UNC\\", RtlPathTypeLocalDevice
},
157 { L
"\\\\?", RtlPathTypeRootLocalDevice
},
158 { L
"\\\\??", RtlPathTypeUncAbsolute
},
159 { L
"\\\\??\\", RtlPathTypeUncAbsolute
},
160 { L
"\\\\??\\C:\\", RtlPathTypeUncAbsolute
},
161 { L
"\\\\.", RtlPathTypeRootLocalDevice
},
162 { L
"\\\\.\\", RtlPathTypeLocalDevice
},
163 { L
"\\\\.\\C:\\", RtlPathTypeLocalDevice
},
164 { L
"\\/", RtlPathTypeUncAbsolute
},
165 { L
"/\\", RtlPathTypeUncAbsolute
},
166 { L
"//", RtlPathTypeUncAbsolute
},
167 { L
"///", RtlPathTypeUncAbsolute
},
168 { L
"//;", RtlPathTypeUncAbsolute
},
169 { L
"//?", RtlPathTypeRootLocalDevice
},
170 { L
"/\\?", RtlPathTypeRootLocalDevice
},
171 { L
"\\/?", RtlPathTypeRootLocalDevice
},
172 { L
"//??", RtlPathTypeUncAbsolute
},
173 { L
"//?" L
"?/", RtlPathTypeUncAbsolute
},
174 { L
"//?" L
"?/C:/", RtlPathTypeUncAbsolute
},
175 { L
"//.", RtlPathTypeRootLocalDevice
},
176 { L
"\\/.", RtlPathTypeRootLocalDevice
},
177 { L
"/\\.", RtlPathTypeRootLocalDevice
},
178 { L
"//./", RtlPathTypeLocalDevice
},
179 { L
"//./C:/", RtlPathTypeLocalDevice
},
180 { L
"%SystemRoot%", RtlPathTypeRelative
},
186 if (!RtlDetermineDosPathNameType_Ustr
)
188 RtlDetermineDosPathNameType_Ustr
= (PVOID
)GetProcAddress(GetModuleHandle(L
"ntdll"), "RtlDetermineDosPathNameType_Ustr");
189 if (!RtlDetermineDosPathNameType_Ustr
)
190 skip("RtlDetermineDosPathNameType_Ustr unavailable\n");
193 StartSeh() RtlDetermineDosPathNameType_U(NULL
); EndSeh(STATUS_ACCESS_VIOLATION
);
195 if (RtlDetermineDosPathNameType_Ustr
)
197 UNICODE_STRING PathString
;
198 StartSeh() RtlDetermineDosPathNameType_Ustr(NULL
); EndSeh(STATUS_ACCESS_VIOLATION
);
200 RtlInitEmptyUnicodeString(&PathString
, NULL
, MAXUSHORT
);
201 PathType
= RtlDetermineDosPathNameType_Ustr(&PathString
);
202 ok(PathType
== RtlPathTypeRelative
, "PathType = %d\n", PathType
);
205 for (i
= 0; i
< sizeof(Tests
) / sizeof(Tests
[0]); i
++)
207 Length
= (USHORT
)wcslen(Tests
[i
].FileName
) * sizeof(WCHAR
);
208 FileName
= AllocateGuarded(Length
+ sizeof(UNICODE_NULL
));
209 RtlCopyMemory(FileName
, Tests
[i
].FileName
, Length
+ sizeof(UNICODE_NULL
));
210 MakeReadOnly(FileName
, Length
+ sizeof(UNICODE_NULL
));
212 PathType
= RtlDetermineDosPathNameType_U(FileName
);
213 ok(PathType
== Tests
[i
].PathType
, "PathType is %d, expected %d for '%S'\n", PathType
, Tests
[i
].PathType
, Tests
[i
].FileName
);
214 EndSeh(STATUS_SUCCESS
);
215 FreeGuarded(FileName
);
217 if (RtlDetermineDosPathNameType_Ustr
)
219 UNICODE_STRING PathString
;
221 FileName
= AllocateGuarded(Length
);
222 RtlCopyMemory(FileName
, Tests
[i
].FileName
, Length
);
223 MakeReadOnly(FileName
, Length
);
224 PathString
.Buffer
= FileName
;
225 PathString
.Length
= Length
;
226 PathString
.MaximumLength
= MAXUSHORT
;
228 PathType
= RtlDetermineDosPathNameType_Ustr(&PathString
);
229 ok(PathType
== Tests
[i
].PathType
, "PathType is %d, expected %d for '%S'\n", PathType
, Tests
[i
].PathType
, Tests
[i
].FileName
);
230 EndSeh(STATUS_SUCCESS
);
231 FreeGuarded(FileName
);