2 * Unit test suite for volume functions
4 * Copyright 2006 Stefan Leichter
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
25 #include "wine/ddk/ntddcdvd.h"
28 struct COMPLETE_DVD_LAYER_DESCRIPTOR
30 DVD_DESCRIPTOR_HEADER Header
;
31 DVD_LAYER_DESCRIPTOR Descriptor
;
35 C_ASSERT(sizeof(struct COMPLETE_DVD_LAYER_DESCRIPTOR
) == 22);
38 struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR
40 DVD_DESCRIPTOR_HEADER Header
;
41 DVD_MANUFACTURER_DESCRIPTOR Descriptor
;
45 C_ASSERT(sizeof(struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR
) == 2053);
47 static HINSTANCE hdll
;
48 static BOOL (WINAPI
* pGetVolumeNameForVolumeMountPointA
)(LPCSTR
, LPSTR
, DWORD
);
49 static BOOL (WINAPI
* pGetVolumeNameForVolumeMountPointW
)(LPCWSTR
, LPWSTR
, DWORD
);
50 static HANDLE (WINAPI
*pFindFirstVolumeA
)(LPSTR
,DWORD
);
51 static BOOL (WINAPI
*pFindNextVolumeA
)(HANDLE
,LPSTR
,DWORD
);
52 static BOOL (WINAPI
*pFindVolumeClose
)(HANDLE
);
53 static UINT (WINAPI
*pGetLogicalDriveStringsA
)(UINT
,LPSTR
);
54 static UINT (WINAPI
*pGetLogicalDriveStringsW
)(UINT
,LPWSTR
);
55 static BOOL (WINAPI
*pGetVolumeInformationA
)(LPCSTR
, LPSTR
, DWORD
, LPDWORD
, LPDWORD
, LPDWORD
, LPSTR
, DWORD
);
56 static BOOL (WINAPI
*pGetVolumePathNameA
)(LPCSTR
, LPSTR
, DWORD
);
57 static BOOL (WINAPI
*pGetVolumePathNamesForVolumeNameA
)(LPCSTR
, LPSTR
, DWORD
, LPDWORD
);
58 static BOOL (WINAPI
*pGetVolumePathNamesForVolumeNameW
)(LPCWSTR
, LPWSTR
, DWORD
, LPDWORD
);
60 /* ############################### */
62 static void test_query_dos_deviceA(void)
64 char drivestr
[] = "a:";
65 char *p
, *buffer
, buffer2
[2000];
66 DWORD ret
, ret2
, buflen
=32768;
69 /* callers must guess the buffer size */
70 SetLastError(0xdeadbeef);
71 ret
= QueryDosDeviceA( NULL
, NULL
, 0 );
72 ok(!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
,
73 "QueryDosDeviceA(no buffer): returned %u, le=%u\n", ret
, GetLastError());
75 buffer
= HeapAlloc( GetProcessHeap(), 0, buflen
);
76 SetLastError(0xdeadbeef);
77 ret
= QueryDosDeviceA( NULL
, buffer
, buflen
);
78 ok((ret
&& GetLastError() != ERROR_INSUFFICIENT_BUFFER
),
79 "QueryDosDeviceA failed to return list, last error %u\n", GetLastError());
81 if (ret
&& GetLastError() != ERROR_INSUFFICIENT_BUFFER
) {
84 if (!strlen(p
)) break;
85 ret2
= QueryDosDeviceA( p
, buffer2
, sizeof(buffer2
) );
86 ok(ret2
, "QueryDosDeviceA failed to return current mapping for %s, last error %u\n", p
, GetLastError());
88 if (ret
<= (p
-buffer
)) break;
92 for (;drivestr
[0] <= 'z'; drivestr
[0]++) {
93 /* Older W2K fails with ERROR_INSUFFICIENT_BUFFER when buflen is > 32767 */
94 ret
= QueryDosDeviceA( drivestr
, buffer
, buflen
- 1);
95 ok(ret
|| GetLastError() == ERROR_FILE_NOT_FOUND
,
96 "QueryDosDeviceA failed to return current mapping for %s, last error %u\n", drivestr
, GetLastError());
98 for (p
= buffer
; *p
; p
++) *p
= toupper(*p
);
99 if (strstr(buffer
, "HARDDISK") || strstr(buffer
, "RAMDISK")) found
= TRUE
;
102 ok(found
, "expected at least one devicename to contain HARDDISK or RAMDISK\n");
103 HeapFree( GetProcessHeap(), 0, buffer
);
106 static void test_define_dos_deviceA(void)
112 /* Find an unused drive letter */
115 for (drivestr
[0] = 'a'; drivestr
[0] <= 'z'; drivestr
[0]++) {
116 ret
= QueryDosDeviceA( drivestr
, buf
, sizeof(buf
));
119 if (drivestr
[0] > 'z') {
120 skip("can't test creating a dos drive, none available\n");
124 /* Map it to point to the current directory */
125 ret
= GetCurrentDirectoryA(sizeof(buf
), buf
);
126 ok(ret
, "GetCurrentDir\n");
128 ret
= DefineDosDeviceA(0, drivestr
, buf
);
130 ok(ret
, "Could not make drive %s point to %s!\n", drivestr
, buf
);
133 skip("can't test removing fake drive\n");
135 ret
= DefineDosDeviceA(DDD_REMOVE_DEFINITION
, drivestr
, NULL
);
136 ok(ret
, "Could not remove fake drive %s!\n", drivestr
);
140 static void test_FindFirstVolume(void)
145 /* not present before w2k */
146 if (!pFindFirstVolumeA
) {
147 win_skip("FindFirstVolumeA not found\n");
151 handle
= pFindFirstVolumeA( volume
, 0 );
152 ok( handle
== INVALID_HANDLE_VALUE
, "succeeded with short buffer\n" );
153 ok( GetLastError() == ERROR_MORE_DATA
|| /* XP */
154 GetLastError() == ERROR_FILENAME_EXCED_RANGE
, /* Vista */
155 "wrong error %u\n", GetLastError() );
156 handle
= pFindFirstVolumeA( volume
, 49 );
157 ok( handle
== INVALID_HANDLE_VALUE
, "succeeded with short buffer\n" );
158 ok( GetLastError() == ERROR_FILENAME_EXCED_RANGE
, "wrong error %u\n", GetLastError() );
159 handle
= pFindFirstVolumeA( volume
, 51 );
160 ok( handle
!= INVALID_HANDLE_VALUE
, "failed err %u\n", GetLastError() );
161 if (handle
!= INVALID_HANDLE_VALUE
)
165 ok( strlen(volume
) == 49, "bad volume name %s\n", volume
);
166 ok( !memcmp( volume
, "\\\\?\\Volume{", 11 ), "bad volume name %s\n", volume
);
167 ok( !memcmp( volume
+ 47, "}\\", 2 ), "bad volume name %s\n", volume
);
168 } while (pFindNextVolumeA( handle
, volume
, MAX_PATH
));
169 ok( GetLastError() == ERROR_NO_MORE_FILES
, "wrong error %u\n", GetLastError() );
170 pFindVolumeClose( handle
);
174 static void test_GetVolumeNameForVolumeMountPointA(void)
177 char volume
[MAX_PATH
], path
[] = "c:\\";
178 DWORD len
= sizeof(volume
), reti
;
179 char temp_path
[MAX_PATH
];
181 /* not present before w2k */
182 if (!pGetVolumeNameForVolumeMountPointA
) {
183 win_skip("GetVolumeNameForVolumeMountPointA not found\n");
187 reti
= GetTempPathA(MAX_PATH
, temp_path
);
188 ok(reti
!= 0, "GetTempPathA error %d\n", GetLastError());
189 ok(reti
< MAX_PATH
, "temp path should fit into MAX_PATH\n");
191 ret
= pGetVolumeNameForVolumeMountPointA(path
, volume
, 0);
192 ok(ret
== FALSE
, "GetVolumeNameForVolumeMountPointA succeeded\n");
193 ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE
||
194 GetLastError() == ERROR_INVALID_PARAMETER
, /* Vista */
195 "wrong error, last=%d\n", GetLastError());
197 if (0) { /* these crash on XP */
198 ret
= pGetVolumeNameForVolumeMountPointA(path
, NULL
, len
);
199 ok(ret
== FALSE
, "GetVolumeNameForVolumeMountPointA succeeded\n");
201 ret
= pGetVolumeNameForVolumeMountPointA(NULL
, volume
, len
);
202 ok(ret
== FALSE
, "GetVolumeNameForVolumeMountPointA succeeded\n");
205 ret
= pGetVolumeNameForVolumeMountPointA(path
, volume
, len
);
206 ok(ret
== TRUE
, "GetVolumeNameForVolumeMountPointA failed\n");
207 ok(!strncmp( volume
, "\\\\?\\Volume{", 11),
208 "GetVolumeNameForVolumeMountPointA failed to return valid string <%s>\n",
211 /* test with too small buffer */
212 ret
= pGetVolumeNameForVolumeMountPointA(path
, volume
, 10);
213 ok(ret
== FALSE
&& GetLastError() == ERROR_FILENAME_EXCED_RANGE
,
214 "GetVolumeNameForVolumeMountPointA failed, wrong error returned, was %d, should be ERROR_FILENAME_EXCED_RANGE\n",
217 /* Try on an arbitrary directory */
218 /* On FAT filesystems it seems that GetLastError() is set to
219 ERROR_INVALID_FUNCTION. */
220 ret
= pGetVolumeNameForVolumeMountPointA(temp_path
, volume
, len
);
221 ok(ret
== FALSE
&& (GetLastError() == ERROR_NOT_A_REPARSE_POINT
||
222 GetLastError() == ERROR_INVALID_FUNCTION
),
223 "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
224 temp_path
, GetLastError());
226 /* Try on a nonexistent dos drive */
228 for (;path
[0] <= 'z'; path
[0]++) {
229 ret
= QueryDosDeviceA( path
, volume
, len
);
235 ret
= pGetVolumeNameForVolumeMountPointA(path
, volume
, len
);
236 ok(ret
== FALSE
&& GetLastError() == ERROR_FILE_NOT_FOUND
,
237 "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
238 path
, GetLastError());
240 /* Try without trailing \ and on a nonexistent dos drive */
242 ret
= pGetVolumeNameForVolumeMountPointA(path
, volume
, len
);
243 ok(ret
== FALSE
&& GetLastError() == ERROR_INVALID_NAME
,
244 "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
245 path
, GetLastError());
249 static void test_GetVolumeNameForVolumeMountPointW(void)
252 WCHAR volume
[MAX_PATH
], path
[] = {'c',':','\\',0};
253 DWORD len
= sizeof(volume
) / sizeof(WCHAR
);
255 /* not present before w2k */
256 if (!pGetVolumeNameForVolumeMountPointW
) {
257 win_skip("GetVolumeNameForVolumeMountPointW not found\n");
261 ret
= pGetVolumeNameForVolumeMountPointW(path
, volume
, 0);
262 ok(ret
== FALSE
, "GetVolumeNameForVolumeMountPointA succeeded\n");
263 ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE
||
264 GetLastError() == ERROR_INVALID_PARAMETER
, /* Vista */
265 "wrong error, last=%d\n", GetLastError());
267 if (0) { /* these crash on XP */
268 ret
= pGetVolumeNameForVolumeMountPointW(path
, NULL
, len
);
269 ok(ret
== FALSE
, "GetVolumeNameForVolumeMountPointW succeeded\n");
271 ret
= pGetVolumeNameForVolumeMountPointW(NULL
, volume
, len
);
272 ok(ret
== FALSE
, "GetVolumeNameForVolumeMountPointW succeeded\n");
275 ret
= pGetVolumeNameForVolumeMountPointW(path
, volume
, len
);
276 ok(ret
== TRUE
, "GetVolumeNameForVolumeMountPointW failed\n");
279 static void test_GetLogicalDriveStringsA(void)
284 ok( pGetLogicalDriveStringsA
!= NULL
, "GetLogicalDriveStringsA not available\n");
285 if(!pGetLogicalDriveStringsA
) {
289 size
= pGetLogicalDriveStringsA(0, NULL
);
290 ok(size
%4 == 1, "size = %d\n", size
);
292 buf
= HeapAlloc(GetProcessHeap(), 0, size
);
295 size2
= pGetLogicalDriveStringsA(2, buf
);
296 ok(size2
== size
, "size2 = %d\n", size2
);
297 ok(!*buf
, "buf changed\n");
299 size2
= pGetLogicalDriveStringsA(size
, buf
);
300 ok(size2
== size
-1, "size2 = %d\n", size2
);
302 for(ptr
= buf
; ptr
< buf
+size2
; ptr
+= 4) {
303 ok(('A' <= *ptr
&& *ptr
<= 'Z'), "device name '%c' is not uppercase\n", *ptr
);
304 ok(ptr
[1] == ':', "ptr[1] = %c, expected ':'\n", ptr
[1]);
305 ok(ptr
[2] == '\\', "ptr[2] = %c expected '\\'\n", ptr
[2]);
306 ok(!ptr
[3], "ptr[3] = %c expected nullbyte\n", ptr
[3]);
308 ok(!*ptr
, "buf[size2] is not nullbyte\n");
310 HeapFree(GetProcessHeap(), 0, buf
);
313 static void test_GetLogicalDriveStringsW(void)
318 ok( pGetLogicalDriveStringsW
!= NULL
, "GetLogicalDriveStringsW not available\n");
319 if(!pGetLogicalDriveStringsW
) {
323 SetLastError(0xdeadbeef);
324 size
= pGetLogicalDriveStringsW(0, NULL
);
325 if (size
== 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
) {
326 win_skip("GetLogicalDriveStringsW not implemented\n");
329 ok(size
%4 == 1, "size = %d\n", size
);
331 buf
= HeapAlloc(GetProcessHeap(), 0, size
*sizeof(WCHAR
));
334 size2
= pGetLogicalDriveStringsW(2, buf
);
335 ok(size2
== size
, "size2 = %d\n", size2
);
336 ok(!*buf
, "buf changed\n");
338 size2
= pGetLogicalDriveStringsW(size
, buf
);
339 ok(size2
== size
-1, "size2 = %d\n", size2
);
341 for(ptr
= buf
; ptr
< buf
+size2
; ptr
+= 4) {
342 ok('A' <= *ptr
&& *ptr
<= 'Z', "device name '%c' is not uppercase\n", *ptr
);
343 ok(ptr
[1] == ':', "ptr[1] = %c, expected ':'\n", ptr
[1]);
344 ok(ptr
[2] == '\\', "ptr[2] = %c expected '\\'\n", ptr
[2]);
345 ok(!ptr
[3], "ptr[3] = %c expected nullbyte\n", ptr
[3]);
347 ok(!*ptr
, "buf[size2] is not nullbyte\n");
349 HeapFree(GetProcessHeap(), 0, buf
);
352 static void test_GetVolumeInformationA(void)
356 char Root_Colon
[]="C:";
357 char Root_Slash
[]="C:\\";
358 char Root_UNC
[]="\\\\?\\C:\\";
359 char volume
[MAX_PATH
+1];
360 DWORD vol_name_size
=MAX_PATH
+1, vol_serial_num
=-1, max_comp_len
=0, fs_flags
=0, fs_name_len
=MAX_PATH
+1;
361 char vol_name_buf
[MAX_PATH
+1], fs_name_buf
[MAX_PATH
+1];
362 char windowsdir
[MAX_PATH
+10];
363 char currentdir
[MAX_PATH
+1];
365 ok( pGetVolumeInformationA
!= NULL
, "GetVolumeInformationA not found\n");
366 if(!pGetVolumeInformationA
) {
370 /* get windows drive letter and update strings for testing */
371 result
= GetWindowsDirectoryA(windowsdir
, sizeof(windowsdir
));
372 ok(result
< sizeof(windowsdir
), "windowsdir is abnormally long!\n");
373 ok(result
!= 0, "GetWindowsDirectory: error %d\n", GetLastError());
374 Root_Colon
[0] = windowsdir
[0];
375 Root_Slash
[0] = windowsdir
[0];
376 Root_UNC
[4] = windowsdir
[0];
378 result
= GetCurrentDirectoryA(MAX_PATH
, currentdir
);
379 ok(result
, "GetCurrentDirectory: error %d\n", GetLastError());
380 /* Note that GetCurrentDir yields no trailing slash for subdirs */
382 /* check for NO error on no trailing \ when current dir is root dir */
383 ret
= SetCurrentDirectoryA(Root_Slash
);
384 ok(ret
, "SetCurrentDirectory: error %d\n", GetLastError());
385 ret
= pGetVolumeInformationA(Root_Colon
, vol_name_buf
, vol_name_size
, NULL
,
386 NULL
, NULL
, fs_name_buf
, fs_name_len
);
387 ok(ret
, "GetVolumeInformationA root failed, last error %u\n", GetLastError());
389 /* check for error on no trailing \ when current dir is subdir (windows) of queried drive */
390 ret
= SetCurrentDirectoryA(windowsdir
);
391 ok(ret
, "SetCurrentDirectory: error %d\n", GetLastError());
392 SetLastError(0xdeadbeef);
393 ret
= pGetVolumeInformationA(Root_Colon
, vol_name_buf
, vol_name_size
, NULL
,
394 NULL
, NULL
, fs_name_buf
, fs_name_len
);
395 ok(!ret
&& (GetLastError() == ERROR_INVALID_NAME
),
396 "GetVolumeInformationA did%s fail, last error %u\n", ret
? " not":"", GetLastError());
398 /* reset current directory */
399 ret
= SetCurrentDirectoryA(currentdir
);
400 ok(ret
, "SetCurrentDirectory: error %d\n", GetLastError());
402 if (toupper(currentdir
[0]) == toupper(windowsdir
[0])) {
403 skip("Please re-run from another device than %c:\n", windowsdir
[0]);
404 /* FIXME: Use GetLogicalDrives to find another device to avoid this skip. */
406 char Root_Env
[]="=C:"; /* where MS maintains the per volume directory */
407 Root_Env
[1] = windowsdir
[0];
409 /* C:\windows becomes the current directory on drive C: */
410 /* Note that paths to subdirs are stored without trailing slash, like what GetCurrentDir yields. */
411 ret
= SetEnvironmentVariableA(Root_Env
, windowsdir
);
412 ok(ret
, "SetEnvironmentVariable %s failed\n", Root_Env
);
414 ret
= SetCurrentDirectoryA(windowsdir
);
415 ok(ret
, "SetCurrentDirectory: error %d\n", GetLastError());
416 ret
= SetCurrentDirectoryA(currentdir
);
417 ok(ret
, "SetCurrentDirectory: error %d\n", GetLastError());
419 /* windows dir is current on the root drive, call fails */
420 SetLastError(0xdeadbeef);
421 ret
= pGetVolumeInformationA(Root_Colon
, vol_name_buf
, vol_name_size
, NULL
,
422 NULL
, NULL
, fs_name_buf
, fs_name_len
);
423 ok(!ret
&& (GetLastError() == ERROR_INVALID_NAME
),
424 "GetVolumeInformationA did%s fail, last error %u\n", ret
? " not":"", GetLastError());
426 /* Try normal drive letter with trailing \ */
427 ret
= pGetVolumeInformationA(Root_Slash
, vol_name_buf
, vol_name_size
, NULL
,
428 NULL
, NULL
, fs_name_buf
, fs_name_len
);
429 ok(ret
, "GetVolumeInformationA with \\ failed, last error %u\n", GetLastError());
431 ret
= SetCurrentDirectoryA(Root_Slash
);
432 ok(ret
, "SetCurrentDirectory: error %d\n", GetLastError());
433 ret
= SetCurrentDirectoryA(currentdir
);
434 ok(ret
, "SetCurrentDirectory: error %d\n", GetLastError());
436 /* windows dir is STILL CURRENT on root drive; the call fails as before, */
437 /* proving that SetCurrentDir did not remember the other drive's directory */
438 SetLastError(0xdeadbeef);
439 ret
= pGetVolumeInformationA(Root_Colon
, vol_name_buf
, vol_name_size
, NULL
,
440 NULL
, NULL
, fs_name_buf
, fs_name_len
);
441 ok(!ret
&& (GetLastError() == ERROR_INVALID_NAME
),
442 "GetVolumeInformationA did%s fail, last error %u\n", ret
? " not":"", GetLastError());
444 /* Now C:\ becomes the current directory on drive C: */
445 ret
= SetEnvironmentVariableA(Root_Env
, Root_Slash
); /* set =C:=C:\ */
446 ok(ret
, "SetEnvironmentVariable %s failed\n", Root_Env
);
448 /* \ is current on root drive, call succeeds */
449 ret
= pGetVolumeInformationA(Root_Colon
, vol_name_buf
, vol_name_size
, NULL
,
450 NULL
, NULL
, fs_name_buf
, fs_name_len
);
451 ok(ret
, "GetVolumeInformationA failed, last error %u\n", GetLastError());
453 /* again, SetCurrentDirectory on another drive does not matter */
454 ret
= SetCurrentDirectoryA(Root_Slash
);
455 ok(ret
, "SetCurrentDirectory: error %d\n", GetLastError());
456 ret
= SetCurrentDirectoryA(currentdir
);
457 ok(ret
, "SetCurrentDirectory: error %d\n", GetLastError());
459 /* \ is current on root drive, call succeeds */
460 ret
= pGetVolumeInformationA(Root_Colon
, vol_name_buf
, vol_name_size
, NULL
,
461 NULL
, NULL
, fs_name_buf
, fs_name_len
);
462 ok(ret
, "GetVolumeInformationA failed, last error %u\n", GetLastError());
465 /* try null root directory to return "root of the current directory" */
466 ret
= pGetVolumeInformationA(NULL
, vol_name_buf
, vol_name_size
, NULL
,
467 NULL
, NULL
, fs_name_buf
, fs_name_len
);
468 ok(ret
, "GetVolumeInformationA failed on null root dir, last error %u\n", GetLastError());
470 /* Try normal drive letter with trailing \ */
471 ret
= pGetVolumeInformationA(Root_Slash
, vol_name_buf
, vol_name_size
,
472 &vol_serial_num
, &max_comp_len
, &fs_flags
, fs_name_buf
, fs_name_len
);
473 ok(ret
, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Slash
, GetLastError());
475 /* try again with drive letter and the "disable parsing" prefix */
476 SetLastError(0xdeadbeef);
477 ret
= pGetVolumeInformationA(Root_UNC
, vol_name_buf
, vol_name_size
,
478 &vol_serial_num
, &max_comp_len
, &fs_flags
, fs_name_buf
, fs_name_len
);
479 ok(ret
, "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret
? " not":"", Root_UNC
, GetLastError());
481 /* try again with device name space */
483 SetLastError(0xdeadbeef);
484 ret
= pGetVolumeInformationA(Root_UNC
, vol_name_buf
, vol_name_size
,
485 &vol_serial_num
, &max_comp_len
, &fs_flags
, fs_name_buf
, fs_name_len
);
486 ok(ret
, "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret
? " not":"", Root_UNC
, GetLastError());
488 /* try again with a directory off the root - should generate error */
489 if (windowsdir
[strlen(windowsdir
)-1] != '\\') strcat(windowsdir
, "\\");
490 SetLastError(0xdeadbeef);
491 ret
= pGetVolumeInformationA(windowsdir
, vol_name_buf
, vol_name_size
,
492 &vol_serial_num
, &max_comp_len
, &fs_flags
, fs_name_buf
, fs_name_len
);
493 ok(!ret
&& (GetLastError()==ERROR_DIR_NOT_ROOT
),
494 "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret
? " not":"", windowsdir
, GetLastError());
495 /* A subdir with trailing \ yields DIR_NOT_ROOT instead of INVALID_NAME */
496 if (windowsdir
[strlen(windowsdir
)-1] == '\\') windowsdir
[strlen(windowsdir
)-1] = 0;
497 SetLastError(0xdeadbeef);
498 ret
= pGetVolumeInformationA(windowsdir
, vol_name_buf
, vol_name_size
,
499 &vol_serial_num
, &max_comp_len
, &fs_flags
, fs_name_buf
, fs_name_len
);
500 ok(!ret
&& (GetLastError()==ERROR_INVALID_NAME
),
501 "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret
? " not":"", windowsdir
, GetLastError());
503 if (!pGetVolumeNameForVolumeMountPointA
) {
504 win_skip("GetVolumeNameForVolumeMountPointA not found\n");
507 /* get the unique volume name for the windows drive */
508 ret
= pGetVolumeNameForVolumeMountPointA(Root_Slash
, volume
, MAX_PATH
);
509 ok(ret
== TRUE
, "GetVolumeNameForVolumeMountPointA failed\n");
511 /* try again with unique volume name */
512 ret
= pGetVolumeInformationA(volume
, vol_name_buf
, vol_name_size
,
513 &vol_serial_num
, &max_comp_len
, &fs_flags
, fs_name_buf
, fs_name_len
);
514 ok(ret
, "GetVolumeInformationA failed, root=%s, last error=%u\n", volume
, GetLastError());
517 /* Test to check that unique volume name from windows dir mount point */
518 /* matches at least one of the unique volume names returned from the */
519 /* FindFirstVolumeA/FindNextVolumeA list. */
520 static void test_enum_vols(void)
523 HANDLE hFind
= INVALID_HANDLE_VALUE
;
524 char Volume_1
[MAX_PATH
] = {0};
525 char Volume_2
[MAX_PATH
] = {0};
526 char path
[] = "c:\\";
528 char windowsdir
[MAX_PATH
];
530 if (!pGetVolumeNameForVolumeMountPointA
) {
531 win_skip("GetVolumeNameForVolumeMountPointA not found\n");
535 /*get windows drive letter and update strings for testing */
536 ret
= GetWindowsDirectoryA( windowsdir
, sizeof(windowsdir
) );
537 ok(ret
< sizeof(windowsdir
), "windowsdir is abnormally long!\n");
538 ok(ret
!= 0, "GetWindowsDirecory: error %d\n", GetLastError());
539 path
[0] = windowsdir
[0];
541 /* get the unique volume name for the windows drive */
542 ret
= pGetVolumeNameForVolumeMountPointA( path
, Volume_1
, MAX_PATH
);
543 ok(ret
== TRUE
, "GetVolumeNameForVolumeMountPointA failed\n");
544 ok(strlen(Volume_1
) == 49, "GetVolumeNameForVolumeMountPointA returned wrong length name %s\n", Volume_1
);
546 /* get first unique volume name of list */
547 hFind
= pFindFirstVolumeA( Volume_2
, MAX_PATH
);
548 ok(hFind
!= INVALID_HANDLE_VALUE
, "FindFirstVolume failed, err=%u\n",
551 if (hFind
!= INVALID_HANDLE_VALUE
) {
554 /* validate correct length of unique volume name */
555 ok(strlen(Volume_2
) == 49, "Find[First/Next]Volume returned wrong length name %s\n", Volume_1
);
556 if (memcmp(Volume_1
, Volume_2
, 49) == 0)
561 } while (pFindNextVolumeA( hFind
, Volume_2
, MAX_PATH
));
562 ok(found
, "volume name %s not found by Find[First/Next]Volume\n", Volume_1
);
563 pFindVolumeClose( hFind
);
567 static void test_disk_extents(void)
572 static DWORD data
[16];
574 handle
= CreateFileA( "\\\\.\\c:", GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
575 if (handle
== INVALID_HANDLE_VALUE
)
577 win_skip("can't open c: drive %u\n", GetLastError());
581 ret
= DeviceIoControl( handle
, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
, &data
,
582 sizeof(data
), &data
, sizeof(data
), &size
, NULL
);
583 if (!ret
&& GetLastError() == ERROR_INVALID_FUNCTION
)
585 win_skip("IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS not supported\n");
586 CloseHandle( handle
);
589 ok(ret
, "DeviceIoControl failed %u\n", GetLastError());
590 ok(size
== 32, "expected 32, got %u\n", size
);
591 CloseHandle( handle
);
594 static void test_GetVolumePathNameA(void)
597 char volume
[MAX_PATH
];
598 char expected
[] = "C:\\", pathC1
[] = "C:\\", pathC2
[] = "C::";
601 if (!pGetVolumePathNameA
)
603 win_skip("required functions not found\n");
607 SetLastError( 0xdeadbeef );
608 ret
= pGetVolumePathNameA(NULL
, NULL
, 0);
609 error
= GetLastError();
610 ok(!ret
, "expected failure\n");
611 ok(error
== ERROR_INVALID_PARAMETER
612 || broken( error
== 0xdeadbeef) /* <=XP */,
613 "expected ERROR_INVALID_PARAMETER got %u\n", error
);
615 SetLastError( 0xdeadbeef );
616 ret
= pGetVolumePathNameA("", NULL
, 0);
617 error
= GetLastError();
618 ok(!ret
, "expected failure\n");
619 ok(error
== ERROR_INVALID_PARAMETER
620 || broken( error
== 0xdeadbeef) /* <=XP */,
621 "expected ERROR_INVALID_PARAMETER got %u\n", error
);
623 SetLastError( 0xdeadbeef );
624 ret
= pGetVolumePathNameA(pathC1
, NULL
, 0);
625 error
= GetLastError();
626 ok(!ret
, "expected failure\n");
627 ok(error
== ERROR_INVALID_PARAMETER
628 || broken(error
== ERROR_FILENAME_EXCED_RANGE
) /* <=XP */,
629 "expected ERROR_INVALID_PARAMETER got %u\n", error
);
631 SetLastError( 0xdeadbeef );
632 ret
= pGetVolumePathNameA(pathC1
, volume
, 0);
633 error
= GetLastError();
634 ok(!ret
, "expected failure\n");
635 ok(error
== ERROR_INVALID_PARAMETER
636 || broken(error
== ERROR_FILENAME_EXCED_RANGE
) /* <=XP */,
637 "expected ERROR_INVALID_PARAMETER got %u\n", error
);
639 SetLastError( 0xdeadbeef );
640 ret
= pGetVolumePathNameA(pathC1
, volume
, 1);
641 error
= GetLastError();
642 ok(!ret
, "expected failure\n");
643 ok(error
== ERROR_FILENAME_EXCED_RANGE
, "expected ERROR_FILENAME_EXCED_RANGE got %u\n", error
);
646 ret
= pGetVolumePathNameA(pathC1
, volume
, sizeof(volume
));
647 ok(ret
, "expected success\n");
648 ok(!strcmp(expected
, volume
), "expected name '%s', returned '%s'\n", pathC1
, volume
);
650 pathC1
[0] = tolower(pathC1
[0]);
652 ret
= pGetVolumePathNameA(pathC1
, volume
, sizeof(volume
));
653 ok(ret
, "expected success\n");
655 ok(!strcmp(expected
, volume
) || broken(!strcasecmp(expected
, volume
)) /* <=XP */,
656 "expected name '%s', returned '%s'\n", expected
, volume
);
659 ret
= pGetVolumePathNameA(pathC2
, volume
, sizeof(volume
));
661 ok(ret
, "expected success\n");
663 ok(!strcmp(expected
, volume
), "expected name '%s', returned '%s'\n", expected
, volume
);
665 /* test an invalid path */
666 SetLastError( 0xdeadbeef );
667 ret
= pGetVolumePathNameA("\\\\$$$", volume
, 1);
668 error
= GetLastError();
669 ok(!ret
, "expected failure\n");
670 ok(error
== ERROR_INVALID_NAME
|| broken(ERROR_FILENAME_EXCED_RANGE
) /* <=2000 */,
671 "expected ERROR_INVALID_NAME got %u\n", error
);
674 static void test_GetVolumePathNamesForVolumeNameA(void)
677 char volume
[MAX_PATH
], buffer
[MAX_PATH
];
680 if (!pGetVolumePathNamesForVolumeNameA
|| !pGetVolumeNameForVolumeMountPointA
)
682 win_skip("required functions not found\n");
686 ret
= pGetVolumeNameForVolumeMountPointA( "c:\\", volume
, sizeof(volume
) );
687 ok(ret
, "failed to get volume name %u\n", GetLastError());
688 trace("c:\\ -> %s\n", volume
);
690 SetLastError( 0xdeadbeef );
691 ret
= pGetVolumePathNamesForVolumeNameA( NULL
, NULL
, 0, NULL
);
692 error
= GetLastError();
693 ok(!ret
, "expected failure\n");
694 ok(error
== ERROR_INVALID_NAME
, "expected ERROR_INVALID_NAME got %u\n", error
);
696 SetLastError( 0xdeadbeef );
697 ret
= pGetVolumePathNamesForVolumeNameA( "", NULL
, 0, NULL
);
698 error
= GetLastError();
699 ok(!ret
, "expected failure\n");
700 ok(error
== ERROR_INVALID_NAME
, "expected ERROR_INVALID_NAME got %u\n", error
);
702 SetLastError( 0xdeadbeef );
703 ret
= pGetVolumePathNamesForVolumeNameA( volume
, NULL
, 0, NULL
);
704 error
= GetLastError();
705 ok(!ret
, "expected failure\n");
706 ok(error
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA got %u\n", error
);
708 SetLastError( 0xdeadbeef );
709 ret
= pGetVolumePathNamesForVolumeNameA( volume
, buffer
, 0, NULL
);
710 error
= GetLastError();
711 ok(!ret
, "expected failure\n");
712 ok(error
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA got %u\n", error
);
714 memset( buffer
, 0xff, sizeof(buffer
) );
715 ret
= pGetVolumePathNamesForVolumeNameA( volume
, buffer
, sizeof(buffer
), NULL
);
716 ok(ret
, "failed to get path names %u\n", GetLastError());
717 ok(!strcmp( "C:\\", buffer
), "expected \"\\C:\" got \"%s\"\n", buffer
);
718 ok(!buffer
[4], "expected double null-terminated buffer\n");
721 SetLastError( 0xdeadbeef );
722 ret
= pGetVolumePathNamesForVolumeNameA( NULL
, NULL
, 0, &len
);
723 error
= GetLastError();
724 ok(!ret
, "expected failure\n");
725 ok(error
== ERROR_INVALID_NAME
, "expected ERROR_INVALID_NAME got %u\n", error
);
728 SetLastError( 0xdeadbeef );
729 ret
= pGetVolumePathNamesForVolumeNameA( NULL
, NULL
, sizeof(buffer
), &len
);
730 error
= GetLastError();
731 ok(!ret
, "expected failure\n");
732 ok(error
== ERROR_INVALID_NAME
, "expected ERROR_INVALID_NAME got %u\n", error
);
735 SetLastError( 0xdeadbeef );
736 ret
= pGetVolumePathNamesForVolumeNameA( NULL
, buffer
, sizeof(buffer
), &len
);
737 error
= GetLastError();
738 ok(!ret
, "expected failure\n");
739 ok(error
== ERROR_INVALID_NAME
, "expected ERROR_INVALID_NAME got %u\n", error
);
742 SetLastError( 0xdeadbeef );
743 ret
= pGetVolumePathNamesForVolumeNameA( NULL
, buffer
, sizeof(buffer
), &len
);
744 error
= GetLastError();
745 ok(!ret
, "expected failure\n");
746 ok(error
== ERROR_INVALID_NAME
, "expected ERROR_INVALID_NAME got %u\n", error
);
749 memset( buffer
, 0xff, sizeof(buffer
) );
750 ret
= pGetVolumePathNamesForVolumeNameA( volume
, buffer
, sizeof(buffer
), &len
);
751 ok(ret
, "failed to get path names %u\n", GetLastError());
752 ok(len
== 5 || broken(len
== 2), "expected 5 got %u\n", len
);
753 ok(!strcmp( "C:\\", buffer
), "expected \"\\C:\" got \"%s\"\n", buffer
);
754 ok(!buffer
[4], "expected double null-terminated buffer\n");
757 static void test_GetVolumePathNamesForVolumeNameW(void)
759 static const WCHAR empty
[] = {0};
760 static const WCHAR drive_c
[] = {'c',':','\\',0};
761 static const WCHAR volume_null
[] = {'\\','\\','?','\\','V','o','l','u','m','e',
762 '{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0',
763 '-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0','}','\\',0};
765 WCHAR volume
[MAX_PATH
], buffer
[MAX_PATH
];
768 if (!pGetVolumePathNamesForVolumeNameW
|| !pGetVolumeNameForVolumeMountPointW
)
770 win_skip("required functions not found\n");
774 ret
= pGetVolumeNameForVolumeMountPointW( drive_c
, volume
, sizeof(volume
)/sizeof(volume
[0]) );
775 ok(ret
, "failed to get volume name %u\n", GetLastError());
777 SetLastError( 0xdeadbeef );
778 ret
= pGetVolumePathNamesForVolumeNameW( empty
, NULL
, 0, NULL
);
779 error
= GetLastError();
780 ok(!ret
, "expected failure\n");
781 ok(error
== ERROR_INVALID_NAME
, "expected ERROR_INVALID_NAME got %u\n", error
);
783 SetLastError( 0xdeadbeef );
784 ret
= pGetVolumePathNamesForVolumeNameW( volume
, NULL
, 0, NULL
);
785 error
= GetLastError();
786 ok(!ret
, "expected failure\n");
787 ok(error
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA got %u\n", error
);
789 SetLastError( 0xdeadbeef );
790 ret
= pGetVolumePathNamesForVolumeNameW( volume
, buffer
, 0, NULL
);
791 error
= GetLastError();
792 ok(!ret
, "expected failure\n");
793 ok(error
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA got %u\n", error
);
796 ret
= pGetVolumePathNamesForVolumeNameW( volume
, NULL
, sizeof(buffer
), NULL
);
797 ok(ret
, "failed to get path names %u\n", GetLastError());
800 ret
= pGetVolumePathNamesForVolumeNameW( volume
, buffer
, sizeof(buffer
), NULL
);
801 ok(ret
, "failed to get path names %u\n", GetLastError());
804 memset( buffer
, 0xff, sizeof(buffer
) );
805 ret
= pGetVolumePathNamesForVolumeNameW( volume
, buffer
, sizeof(buffer
), &len
);
806 ok(ret
, "failed to get path names %u\n", GetLastError());
807 ok(len
== 5, "expected 5 got %u\n", len
);
808 ok(!buffer
[4], "expected double null-terminated buffer\n");
812 volume
[lstrlenW( volume
) - 1] = 0;
813 SetLastError( 0xdeadbeef );
814 ret
= pGetVolumePathNamesForVolumeNameW( volume
, buffer
, sizeof(buffer
), &len
);
815 error
= GetLastError();
816 ok(!ret
, "expected failure\n");
817 ok(error
== ERROR_INVALID_NAME
, "expected ERROR_INVALID_NAME got %u\n", error
);
822 SetLastError( 0xdeadbeef );
823 ret
= pGetVolumePathNamesForVolumeNameW( volume
, buffer
, sizeof(buffer
), &len
);
824 error
= GetLastError();
825 ok(!ret
, "expected failure\n");
826 todo_wine
ok(error
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER got %u\n", error
);
829 lstrcpyW( volume
, volume_null
);
830 SetLastError( 0xdeadbeef );
831 ret
= pGetVolumePathNamesForVolumeNameW( volume
, buffer
, sizeof(buffer
), &len
);
832 error
= GetLastError();
833 ok(!ret
, "expected failure\n");
834 ok(error
== ERROR_FILE_NOT_FOUND
, "expected ERROR_FILE_NOT_FOUND got %u\n", error
);
837 static void test_dvd_read_structure(HANDLE handle
)
842 DVD_READ_STRUCTURE dvdReadStructure
;
843 DVD_LAYER_DESCRIPTOR dvdLayerDescriptor
;
844 struct COMPLETE_DVD_LAYER_DESCRIPTOR completeDvdLayerDescriptor
;
845 DVD_COPYRIGHT_DESCRIPTOR dvdCopyrightDescriptor
;
846 struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR completeDvdManufacturerDescriptor
;
848 dvdReadStructure
.BlockByteOffset
.QuadPart
= 0;
849 dvdReadStructure
.SessionId
= 0;
850 dvdReadStructure
.LayerNumber
= 0;
853 /* DvdPhysicalDescriptor */
854 dvdReadStructure
.Format
= 0;
856 SetLastError(0xdeadbeef);
858 /* Test whether this ioctl is supported */
859 ret
= DeviceIoControl(handle
, IOCTL_DVD_READ_STRUCTURE
, &dvdReadStructure
, sizeof(DVD_READ_STRUCTURE
),
860 &completeDvdLayerDescriptor
, sizeof(struct COMPLETE_DVD_LAYER_DESCRIPTOR
), &nbBytes
, NULL
);
864 skip("IOCTL_DVD_READ_STRUCTURE not supported: %u\n", GetLastError());
868 /* Confirm there is always a header before the actual data */
869 ok( completeDvdLayerDescriptor
.Header
.Length
== 0x0802, "Length is 0x%04x instead of 0x0802\n", completeDvdLayerDescriptor
.Header
.Length
);
870 ok( completeDvdLayerDescriptor
.Header
.Reserved
[0] == 0, "Reserved[0] is %x instead of 0\n", completeDvdLayerDescriptor
.Header
.Reserved
[0]);
871 ok( completeDvdLayerDescriptor
.Header
.Reserved
[1] == 0, "Reserved[1] is %x instead of 0\n", completeDvdLayerDescriptor
.Header
.Reserved
[1]);
873 /* TODO: Also check completeDvdLayerDescriptor.Descriptor content (via IOCTL_SCSI_PASS_THROUGH_DIRECT ?) */
875 /* Insufficient output buffer */
876 for(i
=0; i
<sizeof(DVD_DESCRIPTOR_HEADER
); i
++)
878 SetLastError(0xdeadbeef);
880 ret
= DeviceIoControl(handle
, IOCTL_DVD_READ_STRUCTURE
, &dvdReadStructure
, sizeof(DVD_READ_STRUCTURE
),
881 &completeDvdLayerDescriptor
, i
, &nbBytes
, NULL
);
882 ok(!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
,"IOCTL_DVD_READ_STRUCTURE should fail with small buffer\n");
885 SetLastError(0xdeadbeef);
887 /* On newer version, an output buffer of sizeof(DVD_READ_STRUCTURE) size fails.
888 I think this is to force developers to realize that there is a header before the actual content */
889 ret
= DeviceIoControl(handle
, IOCTL_DVD_READ_STRUCTURE
, &dvdReadStructure
, sizeof(DVD_READ_STRUCTURE
),
890 &dvdLayerDescriptor
, sizeof(DVD_LAYER_DESCRIPTOR
), &nbBytes
, NULL
);
891 ok( (!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
) || broken(ret
) /* < Win7 */,
892 "IOCTL_DVD_READ_STRUCTURE should have failed\n");
894 SetLastError(0xdeadbeef);
896 ret
= DeviceIoControl(handle
, IOCTL_DVD_READ_STRUCTURE
, NULL
, sizeof(DVD_READ_STRUCTURE
),
897 &completeDvdLayerDescriptor
, sizeof(struct COMPLETE_DVD_LAYER_DESCRIPTOR
), &nbBytes
, NULL
);
898 ok( (!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
),
899 "IOCTL_DVD_READ_STRUCTURE should have failed\n");
901 /* Test wrong input parameters */
902 for(i
=0; i
<sizeof(DVD_READ_STRUCTURE
); i
++)
904 SetLastError(0xdeadbeef);
906 ret
= DeviceIoControl(handle
, IOCTL_DVD_READ_STRUCTURE
, &dvdReadStructure
, i
,
907 &completeDvdLayerDescriptor
, sizeof(struct COMPLETE_DVD_LAYER_DESCRIPTOR
), &nbBytes
, NULL
);
908 ok( (!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
),
909 "IOCTL_DVD_READ_STRUCTURE should have failed\n");
913 /* DvdCopyrightDescriptor */
914 dvdReadStructure
.Format
= 1;
916 SetLastError(0xdeadbeef);
918 /* Strangely, with NULL lpOutBuffer, last error is insufficient buffer, not invalid parameter as we could expect */
919 ret
= DeviceIoControl(handle
, IOCTL_DVD_READ_STRUCTURE
, &dvdReadStructure
, sizeof(DVD_READ_STRUCTURE
),
920 NULL
, sizeof(DVD_COPYRIGHT_DESCRIPTOR
), &nbBytes
, NULL
);
921 ok(!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "IOCTL_DVD_READ_STRUCTURE should have failed %d %u\n", ret
, GetLastError());
923 for(i
=0; i
<sizeof(DVD_COPYRIGHT_DESCRIPTOR
); i
++)
925 SetLastError(0xdeadbeef);
927 ret
= DeviceIoControl(handle
, IOCTL_DVD_READ_STRUCTURE
, &dvdReadStructure
, sizeof(DVD_READ_STRUCTURE
),
928 &dvdCopyrightDescriptor
, i
, &nbBytes
, NULL
);
929 ok(!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "IOCTL_DVD_READ_STRUCTURE should have failed %d %u\n", ret
, GetLastError());
933 /* DvdManufacturerDescriptor */
934 dvdReadStructure
.Format
= 4;
936 SetLastError(0xdeadbeef);
938 ret
= DeviceIoControl(handle
, IOCTL_DVD_READ_STRUCTURE
, &dvdReadStructure
, sizeof(DVD_READ_STRUCTURE
),
939 &completeDvdManufacturerDescriptor
, sizeof(DVD_MANUFACTURER_DESCRIPTOR
), &nbBytes
, NULL
);
940 ok(ret
|| broken(GetLastError() == ERROR_NOT_READY
),
941 "IOCTL_DVD_READ_STRUCTURE (DvdManufacturerDescriptor) failed, last error = %u\n", GetLastError());
945 /* Confirm there is always a header before the actual data */
946 ok( completeDvdManufacturerDescriptor
.Header
.Length
== 0x0802, "Length is 0x%04x instead of 0x0802\n", completeDvdManufacturerDescriptor
.Header
.Length
);
947 ok( completeDvdManufacturerDescriptor
.Header
.Reserved
[0] == 0, "Reserved[0] is %x instead of 0\n", completeDvdManufacturerDescriptor
.Header
.Reserved
[0]);
948 ok( completeDvdManufacturerDescriptor
.Header
.Reserved
[1] == 0, "Reserved[1] is %x instead of 0\n", completeDvdManufacturerDescriptor
.Header
.Reserved
[1]);
950 SetLastError(0xdeadbeef);
952 /* Basic parameter check */
953 ret
= DeviceIoControl(handle
, IOCTL_DVD_READ_STRUCTURE
, &dvdReadStructure
, sizeof(DVD_READ_STRUCTURE
),
954 NULL
, sizeof(DVD_MANUFACTURER_DESCRIPTOR
), &nbBytes
, NULL
);
955 ok(!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "IOCTL_DVD_READ_STRUCTURE should have failed %d %u\n", ret
, GetLastError());
958 static void test_cdrom_ioctl(void)
960 char drive_letter
, drive_path
[] = "A:\\", drive_full_path
[] = "\\\\.\\A:";
964 bitmask
= GetLogicalDrives();
967 trace("GetLogicalDrives failed : %u\n", GetLastError());
971 for(drive_letter
='A'; drive_letter
<='Z'; drive_letter
++)
973 if(!(bitmask
& (1 << (drive_letter
-'A') )))
976 drive_path
[0] = drive_letter
;
977 if(GetDriveTypeA(drive_path
) != DRIVE_CDROM
)
979 trace("Skipping %c:, not a CDROM drive.\n", drive_letter
);
983 trace("Testing with %c:\n", drive_letter
);
985 drive_full_path
[4] = drive_letter
;
986 handle
= CreateFileA(drive_full_path
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0);
987 if(handle
== INVALID_HANDLE_VALUE
)
989 trace("Failed to open the device : %u\n", GetLastError());
993 /* Add your tests here */
994 test_dvd_read_structure(handle
);
1003 hdll
= GetModuleHandleA("kernel32.dll");
1004 pGetVolumeNameForVolumeMountPointA
= (void *) GetProcAddress(hdll
, "GetVolumeNameForVolumeMountPointA");
1005 pGetVolumeNameForVolumeMountPointW
= (void *) GetProcAddress(hdll
, "GetVolumeNameForVolumeMountPointW");
1006 pFindFirstVolumeA
= (void *) GetProcAddress(hdll
, "FindFirstVolumeA");
1007 pFindNextVolumeA
= (void *) GetProcAddress(hdll
, "FindNextVolumeA");
1008 pFindVolumeClose
= (void *) GetProcAddress(hdll
, "FindVolumeClose");
1009 pGetLogicalDriveStringsA
= (void *) GetProcAddress(hdll
, "GetLogicalDriveStringsA");
1010 pGetLogicalDriveStringsW
= (void *) GetProcAddress(hdll
, "GetLogicalDriveStringsW");
1011 pGetVolumeInformationA
= (void *) GetProcAddress(hdll
, "GetVolumeInformationA");
1012 pGetVolumePathNameA
= (void *) GetProcAddress(hdll
, "GetVolumePathNameA");
1013 pGetVolumePathNamesForVolumeNameA
= (void *) GetProcAddress(hdll
, "GetVolumePathNamesForVolumeNameA");
1014 pGetVolumePathNamesForVolumeNameW
= (void *) GetProcAddress(hdll
, "GetVolumePathNamesForVolumeNameW");
1016 test_query_dos_deviceA();
1017 test_define_dos_deviceA();
1018 test_FindFirstVolume();
1019 test_GetVolumePathNameA();
1020 test_GetVolumeNameForVolumeMountPointA();
1021 test_GetVolumeNameForVolumeMountPointW();
1022 test_GetLogicalDriveStringsA();
1023 test_GetLogicalDriveStringsW();
1024 test_GetVolumeInformationA();
1026 test_disk_extents();
1027 test_GetVolumePathNamesForVolumeNameA();
1028 test_GetVolumePathNamesForVolumeNameW();