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 <pseh/pseh2.h>
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
;
77 PVOID VirtualMemory
= (PVOID
)PAGE_ROUND_DOWN((SIZE_T
)Pointer
);
80 Status
= NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory
, &Size
, MEM_RELEASE
);
81 ok(Status
== STATUS_SUCCESS
, "Status = %lx\n", Status
);
84 #define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY {
85 #define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus)
87 START_TEST(RtlDetermineDosPathNameType
)
89 NTSTATUS ExceptionStatus
;
90 RTL_PATH_TYPE PathType
;
94 RTL_PATH_TYPE PathType
;
97 { L
"", RtlPathTypeRelative
},
98 { L
"xyz", RtlPathTypeRelative
},
99 { L
"CON", RtlPathTypeRelative
},
100 { L
"NUL", RtlPathTypeRelative
},
101 { L
":", RtlPathTypeRelative
},
102 { L
"::", RtlPathTypeDriveRelative
},
103 { L
":::", RtlPathTypeDriveRelative
},
104 { L
"::::", RtlPathTypeDriveRelative
},
105 { L
"\\", RtlPathTypeRooted
},
106 { L
"\\:", RtlPathTypeRooted
},
107 { L
"\\C:", RtlPathTypeRooted
},
108 { L
"\\C:\\", RtlPathTypeRooted
},
109 { L
"/", RtlPathTypeRooted
},
110 { L
"/:", RtlPathTypeRooted
},
111 { L
"/C:", RtlPathTypeRooted
},
112 { L
"/C:/", RtlPathTypeRooted
},
113 { L
"C", RtlPathTypeRelative
},
114 { L
"C:", RtlPathTypeDriveRelative
},
115 { L
"C:a", RtlPathTypeDriveRelative
},
116 { L
"C:a\\", RtlPathTypeDriveRelative
},
117 { L
"C:\\", RtlPathTypeDriveAbsolute
},
118 { L
"C:/", RtlPathTypeDriveAbsolute
},
119 { L
"C:\\a", RtlPathTypeDriveAbsolute
},
120 { L
"C:/a", RtlPathTypeDriveAbsolute
},
121 { L
"C:\\\\", RtlPathTypeDriveAbsolute
},
122 { L
"\\\\", RtlPathTypeUncAbsolute
},
123 { L
"\\\\\\", RtlPathTypeUncAbsolute
},
124 { L
"\\\\;", RtlPathTypeUncAbsolute
},
125 { L
"\\??\\", RtlPathTypeRooted
},
126 { L
"\\??\\UNC", RtlPathTypeRooted
},
127 { L
"\\??\\UNC\\", RtlPathTypeRooted
},
128 { L
"\\?", RtlPathTypeRooted
},
129 { L
"\\?\\", RtlPathTypeRooted
},
130 { L
"\\?\\UNC", RtlPathTypeRooted
},
131 { L
"\\?\\UNC\\", RtlPathTypeRooted
},
132 { L
"\\\\?\\UNC\\", RtlPathTypeLocalDevice
},
133 { L
"\\\\?", RtlPathTypeRootLocalDevice
},
134 { L
"\\\\??", RtlPathTypeUncAbsolute
},
135 { L
"\\\\??\\", RtlPathTypeUncAbsolute
},
136 { L
"\\\\??\\C:\\", RtlPathTypeUncAbsolute
},
137 { L
"\\\\.", RtlPathTypeRootLocalDevice
},
138 { L
"\\\\.\\", RtlPathTypeLocalDevice
},
139 { L
"\\\\.\\C:\\", RtlPathTypeLocalDevice
},
140 { L
"\\/", RtlPathTypeUncAbsolute
},
141 { L
"/\\", RtlPathTypeUncAbsolute
},
142 { L
"//", RtlPathTypeUncAbsolute
},
143 { L
"///", RtlPathTypeUncAbsolute
},
144 { L
"//;", RtlPathTypeUncAbsolute
},
145 { L
"//?", RtlPathTypeRootLocalDevice
},
146 { L
"/\\?", RtlPathTypeRootLocalDevice
},
147 { L
"\\/?", RtlPathTypeRootLocalDevice
},
148 { L
"//??", RtlPathTypeUncAbsolute
},
149 { L
"//?" L
"?/", RtlPathTypeUncAbsolute
},
150 { L
"//?" L
"?/C:/", RtlPathTypeUncAbsolute
},
151 { L
"//.", RtlPathTypeRootLocalDevice
},
152 { L
"\\/.", RtlPathTypeRootLocalDevice
},
153 { L
"/\\.", RtlPathTypeRootLocalDevice
},
154 { L
"//./", RtlPathTypeLocalDevice
},
155 { L
"//./C:/", RtlPathTypeLocalDevice
},
161 if (!RtlDetermineDosPathNameType_Ustr
)
162 skip(0, "RtlDetermineDosPathNameType_Ustr unavailable\n");
164 StartSeh() RtlDetermineDosPathNameType_U(NULL
); EndSeh(STATUS_ACCESS_VIOLATION
);
166 if (RtlDetermineDosPathNameType_Ustr
)
168 UNICODE_STRING PathString
;
169 StartSeh() RtlDetermineDosPathNameType_Ustr(NULL
); EndSeh(STATUS_ACCESS_VIOLATION
);
171 RtlInitEmptyUnicodeString(&PathString
, NULL
, MAXUSHORT
);
172 PathType
= RtlDetermineDosPathNameType_Ustr(&PathString
);
173 ok(PathType
== RtlPathTypeRelative
, "PathType = %d\n", PathType
);
176 for (i
= 0; i
< sizeof(Tests
) / sizeof(Tests
[0]); i
++)
178 Length
= (USHORT
)wcslen(Tests
[i
].FileName
) * sizeof(WCHAR
);
179 FileName
= AllocateGuarded(Length
+ sizeof(UNICODE_NULL
));
180 RtlCopyMemory(FileName
, Tests
[i
].FileName
, Length
+ sizeof(UNICODE_NULL
));
182 PathType
= RtlDetermineDosPathNameType_U(FileName
);
183 ok(PathType
== Tests
[i
].PathType
, "PathType is %d, expected %d for '%S'\n", PathType
, Tests
[i
].PathType
, Tests
[i
].FileName
);
184 EndSeh(STATUS_SUCCESS
);
185 FreeGuarded(FileName
);
187 if (RtlDetermineDosPathNameType_Ustr
)
189 UNICODE_STRING PathString
;
191 FileName
= AllocateGuarded(Length
);
192 RtlCopyMemory(FileName
, Tests
[i
].FileName
, Length
);
193 PathString
.Buffer
= FileName
;
194 PathString
.Length
= Length
;
195 PathString
.MaximumLength
= MAXUSHORT
;
197 PathType
= RtlDetermineDosPathNameType_Ustr(&PathString
);
198 ok(PathType
== Tests
[i
].PathType
, "PathType is %d, expected %d for '%S'\n", PathType
, Tests
[i
].PathType
, Tests
[i
].FileName
);
199 EndSeh(STATUS_SUCCESS
);
200 FreeGuarded(FileName
);