msxml3: Ignore XML property ResolveExternals.
[wine] / dlls / kernel32 / tests / volume.c
1 /*
2  * Unit test suite for volume functions
3  *
4  * Copyright 2006 Stefan Leichter
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "wine/test.h"
22 #include "winbase.h"
23 #include "winioctl.h"
24 #include <stdio.h>
25
26 static HINSTANCE hdll;
27 static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD);
28 static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD);
29 static HANDLE (WINAPI *pFindFirstVolumeA)(LPSTR,DWORD);
30 static BOOL (WINAPI *pFindNextVolumeA)(HANDLE,LPSTR,DWORD);
31 static BOOL (WINAPI *pFindVolumeClose)(HANDLE);
32 static UINT (WINAPI *pGetLogicalDriveStringsA)(UINT,LPSTR);
33 static UINT (WINAPI *pGetLogicalDriveStringsW)(UINT,LPWSTR);
34 static BOOL (WINAPI *pGetVolumeInformationA)(LPCSTR, LPSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPSTR, DWORD);
35
36 /* ############################### */
37
38 static void test_query_dos_deviceA(void)
39 {
40     char drivestr[] = "a:";
41     char *p, *buffer, buffer2[2000];
42     DWORD ret, ret2, buflen=32768;
43     BOOL found = FALSE;
44
45     buffer = HeapAlloc( GetProcessHeap(), 0, buflen );
46     SetLastError(0xdeadbeef);
47     ret = QueryDosDeviceA( NULL, buffer, buflen );
48     ok((ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER),
49         "QueryDosDeviceA failed to return list, last error %u\n", GetLastError());
50
51     if (ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
52         p = buffer;
53         for (;;) {
54             if (!strlen(p)) break;
55             ret2 = QueryDosDeviceA( p, buffer2, sizeof(buffer2) );
56             ok(ret2, "QueryDosDeviceA failed to return current mapping for %s, last error %u\n", p, GetLastError());
57             p += strlen(p) + 1;
58             if (ret <= (p-buffer)) break;
59         }
60     }
61
62     for (;drivestr[0] <= 'z'; drivestr[0]++) {
63         /* Older W2K fails with ERROR_INSUFFICIENT_BUFFER when buflen is > 32767 */
64         ret = QueryDosDeviceA( drivestr, buffer, buflen - 1);
65         ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND,
66             "QueryDosDeviceA failed to return current mapping for %s, last error %u\n", drivestr, GetLastError());
67         if(ret) {
68             for (p = buffer; *p; p++) *p = toupper(*p);
69             if (strstr(buffer, "HARDDISK") || strstr(buffer, "RAMDISK")) found = TRUE;
70         }
71     }
72     ok(found, "expected at least one devicename to contain HARDDISK or RAMDISK\n");
73     HeapFree( GetProcessHeap(), 0, buffer );
74 }
75
76 static void test_FindFirstVolume(void)
77 {
78     char volume[51];
79     HANDLE handle;
80
81     /* not present before w2k */
82     if (!pFindFirstVolumeA) {
83         win_skip("FindFirstVolumeA not found\n");
84         return;
85     }
86
87     handle = pFindFirstVolumeA( volume, 0 );
88     ok( handle == INVALID_HANDLE_VALUE, "succeeded with short buffer\n" );
89     ok( GetLastError() == ERROR_MORE_DATA ||  /* XP */
90         GetLastError() == ERROR_FILENAME_EXCED_RANGE,  /* Vista */
91         "wrong error %u\n", GetLastError() );
92     handle = pFindFirstVolumeA( volume, 49 );
93     ok( handle == INVALID_HANDLE_VALUE, "succeeded with short buffer\n" );
94     ok( GetLastError() == ERROR_FILENAME_EXCED_RANGE, "wrong error %u\n", GetLastError() );
95     handle = pFindFirstVolumeA( volume, 51 );
96     ok( handle != INVALID_HANDLE_VALUE, "failed err %u\n", GetLastError() );
97     if (handle != INVALID_HANDLE_VALUE)
98     {
99         do
100         {
101             ok( strlen(volume) == 49, "bad volume name %s\n", volume );
102             ok( !memcmp( volume, "\\\\?\\Volume{", 11 ), "bad volume name %s\n", volume );
103             ok( !memcmp( volume + 47, "}\\", 2 ), "bad volume name %s\n", volume );
104         } while (pFindNextVolumeA( handle, volume, MAX_PATH ));
105         ok( GetLastError() == ERROR_NO_MORE_FILES, "wrong error %u\n", GetLastError() );
106         pFindVolumeClose( handle );
107     }
108 }
109
110 static void test_GetVolumeNameForVolumeMountPointA(void)
111 {
112     BOOL ret;
113     char volume[MAX_PATH], path[] = "c:\\";
114     DWORD len = sizeof(volume), reti;
115     char temp_path[MAX_PATH];
116
117     /* not present before w2k */
118     if (!pGetVolumeNameForVolumeMountPointA) {
119         win_skip("GetVolumeNameForVolumeMountPointA not found\n");
120         return;
121     }
122
123     reti = GetTempPathA(MAX_PATH, temp_path);
124     ok(reti != 0, "GetTempPathA error %d\n", GetLastError());
125     ok(reti < MAX_PATH, "temp path should fit into MAX_PATH\n");
126
127     ret = pGetVolumeNameForVolumeMountPointA(path, volume, 0);
128     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
129     ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE ||
130         GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */
131         "wrong error, last=%d\n", GetLastError());
132
133     if (0) { /* these crash on XP */
134     ret = pGetVolumeNameForVolumeMountPointA(path, NULL, len);
135     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
136
137     ret = pGetVolumeNameForVolumeMountPointA(NULL, volume, len);
138     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
139     }
140
141     ret = pGetVolumeNameForVolumeMountPointA(path, volume, len);
142     ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
143     ok(!strncmp( volume, "\\\\?\\Volume{", 11),
144         "GetVolumeNameForVolumeMountPointA failed to return valid string <%s>\n",
145         volume);
146
147     /* test with too small buffer */
148     ret = pGetVolumeNameForVolumeMountPointA(path, volume, 10);
149     ok(ret == FALSE && GetLastError() == ERROR_FILENAME_EXCED_RANGE,
150             "GetVolumeNameForVolumeMountPointA failed, wrong error returned, was %d, should be ERROR_FILENAME_EXCED_RANGE\n",
151              GetLastError());
152
153     /* Try on a arbitrary directory */
154     /* On FAT filesystems it seems that GetLastError() is set to
155        ERROR_INVALID_FUNCTION. */
156     ret = pGetVolumeNameForVolumeMountPointA(temp_path, volume, len);
157     ok(ret == FALSE && (GetLastError() == ERROR_NOT_A_REPARSE_POINT ||
158         GetLastError() == ERROR_INVALID_FUNCTION),
159         "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
160         temp_path, GetLastError());
161
162     /* Try on a nonexistent dos drive */
163     path[2] = 0;
164     for (;path[0] <= 'z'; path[0]++) {
165         ret = QueryDosDeviceA( path, volume, len);
166         if(!ret) break;
167     }
168     if (path[0] <= 'z')
169     {
170         path[2] = '\\';
171         ret = pGetVolumeNameForVolumeMountPointA(path, volume, len);
172         ok(ret == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND,
173             "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
174             path, GetLastError());
175
176         /* Try without trailing \ and on a nonexistent dos drive  */
177         path[2] = 0;
178         ret = pGetVolumeNameForVolumeMountPointA(path, volume, len);
179         ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
180             "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
181             path, GetLastError());
182     }
183 }
184
185 static void test_GetVolumeNameForVolumeMountPointW(void)
186 {
187     BOOL ret;
188     WCHAR volume[MAX_PATH], path[] = {'c',':','\\',0};
189     DWORD len = sizeof(volume) / sizeof(WCHAR);
190
191     /* not present before w2k */
192     if (!pGetVolumeNameForVolumeMountPointW) {
193         win_skip("GetVolumeNameForVolumeMountPointW not found\n");
194         return;
195     }
196
197     ret = pGetVolumeNameForVolumeMountPointW(path, volume, 0);
198     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
199     ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE ||
200         GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */
201         "wrong error, last=%d\n", GetLastError());
202
203     if (0) { /* these crash on XP */
204     ret = pGetVolumeNameForVolumeMountPointW(path, NULL, len);
205     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
206
207     ret = pGetVolumeNameForVolumeMountPointW(NULL, volume, len);
208     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
209     }
210
211     ret = pGetVolumeNameForVolumeMountPointW(path, volume, len);
212     ok(ret == TRUE, "GetVolumeNameForVolumeMountPointW failed\n");
213 }
214
215 static void test_GetLogicalDriveStringsA(void)
216 {
217     UINT size, size2;
218     char *buf, *ptr;
219
220     ok( pGetLogicalDriveStringsA != NULL, "GetLogicalDriveStringsA not available\n");
221     if(!pGetLogicalDriveStringsA) {
222         return;
223     }
224
225     size = pGetLogicalDriveStringsA(0, NULL);
226     ok(size%4 == 1, "size = %d\n", size);
227
228     buf = HeapAlloc(GetProcessHeap(), 0, size);
229
230     *buf = 0;
231     size2 = pGetLogicalDriveStringsA(2, buf);
232     ok(size2 == size, "size2 = %d\n", size2);
233     ok(!*buf, "buf changed\n");
234
235     size2 = pGetLogicalDriveStringsA(size, buf);
236     ok(size2 == size-1, "size2 = %d\n", size2);
237
238     for(ptr = buf; ptr < buf+size2; ptr += 4) {
239         ok(('A' <= *ptr && *ptr <= 'Z'), "device name '%c' is not uppercase\n", *ptr);
240         ok(ptr[1] == ':', "ptr[1] = %c, expected ':'\n", ptr[1]);
241         ok(ptr[2] == '\\', "ptr[2] = %c expected '\\'\n", ptr[2]);
242         ok(!ptr[3], "ptr[3] = %c expected nullbyte\n", ptr[3]);
243     }
244     ok(!*ptr, "buf[size2] is not nullbyte\n");
245
246     HeapFree(GetProcessHeap(), 0, buf);
247 }
248
249 static void test_GetLogicalDriveStringsW(void)
250 {
251     UINT size, size2;
252     WCHAR *buf, *ptr;
253
254     ok( pGetLogicalDriveStringsW != NULL, "GetLogicalDriveStringsW not available\n");
255     if(!pGetLogicalDriveStringsW) {
256         return;
257     }
258
259     SetLastError(0xdeadbeef);
260     size = pGetLogicalDriveStringsW(0, NULL);
261     if (size == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
262         win_skip("GetLogicalDriveStringsW not implemented\n");
263         return;
264     }
265     ok(size%4 == 1, "size = %d\n", size);
266
267     buf = HeapAlloc(GetProcessHeap(), 0, size*sizeof(WCHAR));
268
269     *buf = 0;
270     size2 = pGetLogicalDriveStringsW(2, buf);
271     ok(size2 == size, "size2 = %d\n", size2);
272     ok(!*buf, "buf changed\n");
273
274     size2 = pGetLogicalDriveStringsW(size, buf);
275     ok(size2 == size-1, "size2 = %d\n", size2);
276
277     for(ptr = buf; ptr < buf+size2; ptr += 4) {
278         ok('A' <= *ptr && *ptr <= 'Z', "device name '%c' is not uppercase\n", *ptr);
279         ok(ptr[1] == ':', "ptr[1] = %c, expected ':'\n", ptr[1]);
280         ok(ptr[2] == '\\', "ptr[2] = %c expected '\\'\n", ptr[2]);
281         ok(!ptr[3], "ptr[3] = %c expected nullbyte\n", ptr[3]);
282     }
283     ok(!*ptr, "buf[size2] is not nullbyte\n");
284
285     HeapFree(GetProcessHeap(), 0, buf);
286 }
287
288 static void test_GetVolumeInformationA(void)
289 {
290     BOOL ret;
291     UINT result;
292     char Root_Colon[]="C:";
293     char Root_Slash[]="C:\\";
294     char Root_UNC[]="\\\\?\\C:\\";
295     char volume[MAX_PATH+1];
296     DWORD vol_name_size=MAX_PATH+1, vol_serial_num=-1, max_comp_len=0, fs_flags=0, fs_name_len=MAX_PATH+1;
297     char vol_name_buf[MAX_PATH+1], fs_name_buf[MAX_PATH+1];
298     char windowsdir[MAX_PATH+10];
299     char currentdir[MAX_PATH+1];
300
301     ok( pGetVolumeInformationA != NULL, "GetVolumeInformationA not found\n");
302     if(!pGetVolumeInformationA) {
303         return;
304     }
305
306     /* get windows drive letter and update strings for testing */
307     result = GetWindowsDirectory(windowsdir, sizeof(windowsdir));
308     ok(result < sizeof(windowsdir), "windowsdir is abnormally long!\n");
309     ok(result != 0, "GetWindowsDirectory: error %d\n", GetLastError());
310     Root_Colon[0] = windowsdir[0];
311     Root_Slash[0] = windowsdir[0];
312     Root_UNC[4] = windowsdir[0];
313
314     result = GetCurrentDirectory(MAX_PATH, currentdir);
315     ok(result, "GetCurrentDirectory: error %d\n", GetLastError());
316     /* Note that GetCurrentDir yields no trailing slash for subdirs */
317
318     /* check for NO error on no trailing \ when current dir is root dir */
319     ret = SetCurrentDirectory(Root_Slash);
320     ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
321     ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
322             NULL, NULL, fs_name_buf, fs_name_len);
323     ok(ret, "GetVolumeInformationA root failed, last error %u\n", GetLastError());
324
325     /* check for error on no trailing \ when current dir is subdir (windows) of queried drive */
326     ret = SetCurrentDirectory(windowsdir);
327     ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
328     SetLastError(0xdeadbeef);
329     ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
330             NULL, NULL, fs_name_buf, fs_name_len);
331     ok(!ret && (GetLastError() == ERROR_INVALID_NAME),
332         "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
333
334     /* reset current directory */
335     ret = SetCurrentDirectory(currentdir);
336     ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
337
338     if (toupper(currentdir[0]) == toupper(windowsdir[0])) {
339         skip("Please re-run from another device than %c:\n", windowsdir[0]);
340         /* FIXME: Use GetLogicalDrives to find another device to avoid this skip. */
341     } else {
342         char Root_Env[]="=C:"; /* where MS maintains the per volume directory */
343         Root_Env[1] = windowsdir[0];
344
345         /* C:\windows becomes the current directory on drive C: */
346         /* Note that paths to subdirs are stored without trailing slash, like what GetCurrentDir yields. */
347         ret = SetEnvironmentVariable(Root_Env, windowsdir);
348         ok(ret, "SetEnvironmentVariable %s failed\n", Root_Env);
349
350         ret = SetCurrentDirectory(windowsdir);
351         ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
352         ret = SetCurrentDirectory(currentdir);
353         ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
354
355         /* windows dir is current on the root drive, call fails */
356         SetLastError(0xdeadbeef);
357         ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
358                 NULL, NULL, fs_name_buf, fs_name_len);
359         ok(!ret && (GetLastError() == ERROR_INVALID_NAME),
360            "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
361
362         /* Try normal drive letter with trailing \ */
363         ret = pGetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size, NULL,
364                 NULL, NULL, fs_name_buf, fs_name_len);
365         ok(ret, "GetVolumeInformationA with \\ failed, last error %u\n", GetLastError());
366
367         ret = SetCurrentDirectory(Root_Slash);
368         ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
369         ret = SetCurrentDirectory(currentdir);
370         ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
371
372         /* windows dir is STILL CURRENT on root drive; the call fails as before,   */
373         /* proving that SetCurrentDir did not remember the other drive's directory */
374         SetLastError(0xdeadbeef);
375         ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
376                 NULL, NULL, fs_name_buf, fs_name_len);
377         ok(!ret && (GetLastError() == ERROR_INVALID_NAME),
378            "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
379
380         /* Now C:\ becomes the current directory on drive C: */
381         ret = SetEnvironmentVariable(Root_Env, Root_Slash); /* set =C:=C:\ */
382         ok(ret, "SetEnvironmentVariable %s failed\n", Root_Env);
383
384         /* \ is current on root drive, call succeeds */
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 failed, last error %u\n", GetLastError());
388
389         /* again, SetCurrentDirectory on another drive does not matter */
390         ret = SetCurrentDirectory(Root_Slash);
391         ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
392         ret = SetCurrentDirectory(currentdir);
393         ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
394
395         /* \ is current on root drive, call succeeds */
396         ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
397                 NULL, NULL, fs_name_buf, fs_name_len);
398         ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError());
399     }
400
401     /* try null root directory to return "root of the current directory"  */
402     ret = pGetVolumeInformationA(NULL, vol_name_buf, vol_name_size, NULL,
403             NULL, NULL, fs_name_buf, fs_name_len);
404     ok(ret, "GetVolumeInformationA failed on null root dir, last error %u\n", GetLastError());
405
406     /* Try normal drive letter with trailing \  */
407     ret = pGetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size,
408             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
409     ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Slash, GetLastError());
410
411     /* try again with drive letter and the "disable parsing" prefix */
412     SetLastError(0xdeadbeef);
413     ret = pGetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size,
414             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
415     ok(ret, "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", Root_UNC, GetLastError());
416
417     /* try again with device name space  */
418     Root_UNC[2] = '.';
419     SetLastError(0xdeadbeef);
420     ret = pGetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size,
421             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
422     ok(ret, "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", Root_UNC, GetLastError());
423
424     /* try again with a directory off the root - should generate error  */
425     if (windowsdir[strlen(windowsdir)-1] != '\\') strcat(windowsdir, "\\");
426     SetLastError(0xdeadbeef);
427     ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size,
428             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
429     ok(!ret && (GetLastError()==ERROR_DIR_NOT_ROOT),
430           "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError());
431     /* A subdir with trailing \ yields DIR_NOT_ROOT instead of INVALID_NAME */
432     if (windowsdir[strlen(windowsdir)-1] == '\\') windowsdir[strlen(windowsdir)-1] = 0;
433     SetLastError(0xdeadbeef);
434     ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size,
435             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
436     ok(!ret && (GetLastError()==ERROR_INVALID_NAME),
437           "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError());
438
439     if (!pGetVolumeNameForVolumeMountPointA) {
440         win_skip("GetVolumeNameForVolumeMountPointA not found\n");
441         return;
442     }
443     /* get the unique volume name for the windows drive  */
444     ret = pGetVolumeNameForVolumeMountPointA(Root_Slash, volume, MAX_PATH);
445     ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
446
447     /* try again with unique volume name */
448     ret = pGetVolumeInformationA(volume, vol_name_buf, vol_name_size,
449             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
450     ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", volume, GetLastError());
451 }
452
453 /* Test to check that unique volume name from windows dir mount point  */
454 /* matches at least one of the unique volume names returned from the   */
455 /* FindFirstVolumeA/FindNextVolumeA list.                              */
456 static void test_enum_vols(void)
457 {
458     DWORD   ret;
459     HANDLE  hFind = INVALID_HANDLE_VALUE;
460     char    Volume_1[MAX_PATH] = {0};
461     char    Volume_2[MAX_PATH] = {0};
462     char    path[] = "c:\\";
463     BOOL    found = FALSE;
464     char    windowsdir[MAX_PATH];
465
466     if (!pGetVolumeNameForVolumeMountPointA) {
467         win_skip("GetVolumeNameForVolumeMountPointA not found\n");
468         return;
469     }
470
471     /*get windows drive letter and update strings for testing  */
472     ret = GetWindowsDirectory( windowsdir, sizeof(windowsdir) );
473     ok(ret < sizeof(windowsdir), "windowsdir is abnormally long!\n");
474     ok(ret != 0, "GetWindowsDirecory: error %d\n", GetLastError());
475     path[0] = windowsdir[0];
476
477     /* get the unique volume name for the windows drive  */
478     ret = pGetVolumeNameForVolumeMountPointA( path, Volume_1, MAX_PATH );
479     ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
480     ok(strlen(Volume_1) == 49, "GetVolumeNameForVolumeMountPointA returned wrong length name %s\n", Volume_1);
481
482     /* get first unique volume name of list  */
483     hFind = pFindFirstVolumeA( Volume_2, MAX_PATH );
484     ok(hFind != INVALID_HANDLE_VALUE, "FindFirstVolume failed, err=%u\n",
485                 GetLastError());
486
487     do
488     {
489         /* validate correct length of unique volume name  */
490         ok(strlen(Volume_2) == 49, "Find[First/Next]Volume returned wrong length name %s\n", Volume_1);
491         if (memcmp(Volume_1, Volume_2, 49) == 0)
492         {
493             found = TRUE;
494             break;
495         }
496     } while (pFindNextVolumeA( hFind, Volume_2, MAX_PATH ));
497     ok(found, "volume name %s not found by Find[First/Next]Volume\n", Volume_1);
498     pFindVolumeClose( hFind );
499 }
500
501 static void test_disk_extents(void)
502 {
503     BOOL ret;
504     DWORD size;
505     HANDLE handle;
506     static DWORD data[16];
507
508     handle = CreateFileA( "\\\\.\\c:", GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
509     if (handle == INVALID_HANDLE_VALUE)
510     {
511         win_skip("can't open c: drive %u\n", GetLastError());
512         return;
513     }
514     size = 0;
515     ret = DeviceIoControl( handle, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, &data,
516                            sizeof(data), &data, sizeof(data), &size, NULL );
517     if (!ret && GetLastError() == ERROR_INVALID_FUNCTION)
518     {
519         win_skip("IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS not supported\n");
520         CloseHandle( handle );
521         return;
522     }
523     ok(ret, "DeviceIoControl failed %u\n", GetLastError());
524     ok(size == 32, "expected 32, got %u\n", size);
525     CloseHandle( handle );
526 }
527
528 START_TEST(volume)
529 {
530     hdll = GetModuleHandleA("kernel32.dll");
531     pGetVolumeNameForVolumeMountPointA = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointA");
532     pGetVolumeNameForVolumeMountPointW = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointW");
533     pFindFirstVolumeA = (void *) GetProcAddress(hdll, "FindFirstVolumeA");
534     pFindNextVolumeA = (void *) GetProcAddress(hdll, "FindNextVolumeA");
535     pFindVolumeClose = (void *) GetProcAddress(hdll, "FindVolumeClose");
536     pGetLogicalDriveStringsA = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsA");
537     pGetLogicalDriveStringsW = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsW");
538     pGetVolumeInformationA = (void *) GetProcAddress(hdll, "GetVolumeInformationA");
539
540     test_query_dos_deviceA();
541     test_FindFirstVolume();
542     test_GetVolumeNameForVolumeMountPointA();
543     test_GetVolumeNameForVolumeMountPointW();
544     test_GetLogicalDriveStringsA();
545     test_GetLogicalDriveStringsW();
546     test_GetVolumeInformationA();
547     test_enum_vols();
548     test_disk_extents();
549 }