[KERNEL32_WINETEST]
[reactos.git] / rostests / winetests / kernel32 / volume.c
index f94d9cb..1d02782 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "wine/test.h"
 #include "winbase.h"
+#include "winioctl.h"
 #include <stdio.h>
 
 static HINSTANCE hdll;
@@ -31,6 +32,8 @@ static BOOL (WINAPI *pFindVolumeClose)(HANDLE);
 static UINT (WINAPI *pGetLogicalDriveStringsA)(UINT,LPSTR);
 static UINT (WINAPI *pGetLogicalDriveStringsW)(UINT,LPWSTR);
 static BOOL (WINAPI *pGetVolumeInformationA)(LPCSTR, LPSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPSTR, DWORD);
+static BOOL (WINAPI *pGetVolumePathNamesForVolumeNameA)(LPCSTR, LPSTR, DWORD, LPDWORD);
+static BOOL (WINAPI *pGetVolumePathNamesForVolumeNameW)(LPCWSTR, LPWSTR, DWORD, LPDWORD);
 
 /* ############################### */
 
@@ -41,21 +44,19 @@ static void test_query_dos_deviceA(void)
     DWORD ret, ret2, buflen=32768;
     BOOL found = FALSE;
 
-    if (!pFindFirstVolumeA) {
-        win_skip("On win9x, HARDDISK and RAMDISK not present\n");
-        return;
-    }
+    /* callers must guess the buffer size */
+    SetLastError(0xdeadbeef);
+    ret = QueryDosDeviceA( NULL, NULL, 0 );
+    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
+       "QueryDosDeviceA(no buffer): returned %u, le=%u\n", ret, GetLastError());
 
     buffer = HeapAlloc( GetProcessHeap(), 0, buflen );
+    SetLastError(0xdeadbeef);
     ret = QueryDosDeviceA( NULL, buffer, buflen );
-    ok(ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER,
-        "QueryDosDevice buffer too small\n");
-    if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-        HeapFree( GetProcessHeap(), 0, buffer );
-        return;
-    }
-    ok(ret, "QueryDosDeviceA failed to return list, last error %u\n", GetLastError());
-    if (ret) {
+    ok((ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER),
+        "QueryDosDeviceA failed to return list, last error %u\n", GetLastError());
+
+    if (ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
         p = buffer;
         for (;;) {
             if (!strlen(p)) break;
@@ -69,6 +70,8 @@ static void test_query_dos_deviceA(void)
     for (;drivestr[0] <= 'z'; drivestr[0]++) {
         /* Older W2K fails with ERROR_INSUFFICIENT_BUFFER when buflen is > 32767 */
         ret = QueryDosDeviceA( drivestr, buffer, buflen - 1);
+        ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND,
+            "QueryDosDeviceA failed to return current mapping for %s, last error %u\n", drivestr, GetLastError());
         if(ret) {
             for (p = buffer; *p; p++) *p = toupper(*p);
             if (strstr(buffer, "HARDDISK") || strstr(buffer, "RAMDISK")) found = TRUE;
@@ -78,13 +81,48 @@ static void test_query_dos_deviceA(void)
     HeapFree( GetProcessHeap(), 0, buffer );
 }
 
+static void test_define_dos_deviceA(void)
+{
+    char drivestr[3];
+    char buf[MAX_PATH];
+    DWORD ret;
+
+    /* Find an unused drive letter */
+    drivestr[1] = ':';
+    drivestr[2] = 0;
+    for (drivestr[0] = 'a'; drivestr[0] <= 'z'; drivestr[0]++) {
+        ret = QueryDosDeviceA( drivestr, buf, sizeof(buf));
+        if (!ret) break;
+    }
+    if (drivestr[0] > 'z') {
+        skip("can't test creating a dos drive, none available\n");
+        return;
+    }
+
+    /* Map it to point to the current directory */
+    ret = GetCurrentDirectory(sizeof(buf), buf);
+    ok(ret, "GetCurrentDir\n");
+
+    ret = DefineDosDeviceA(0, drivestr, buf);
+    todo_wine
+    ok(ret, "Could not make drive %s point to %s!\n", drivestr, buf);
+
+    if (!ret) {
+        skip("can't test removing fake drive\n");
+    } else {
+       ret = DefineDosDeviceA(DDD_REMOVE_DEFINITION, drivestr, NULL);
+       ok(ret, "Could not remove fake drive %s!\n", drivestr);
+    }
+}
+
 static void test_FindFirstVolume(void)
 {
     char volume[51];
     HANDLE handle;
 
+    /* not present before w2k */
     if (!pFindFirstVolumeA) {
-        skip("FindFirstVolumeA not found\n");
+        win_skip("FindFirstVolumeA not found\n");
         return;
     }
 
@@ -120,7 +158,7 @@ static void test_GetVolumeNameForVolumeMountPointA(void)
 
     /* not present before w2k */
     if (!pGetVolumeNameForVolumeMountPointA) {
-        skip("GetVolumeNameForVolumeMountPointA not found\n");
+        win_skip("GetVolumeNameForVolumeMountPointA not found\n");
         return;
     }
 
@@ -194,7 +232,7 @@ static void test_GetVolumeNameForVolumeMountPointW(void)
 
     /* not present before w2k */
     if (!pGetVolumeNameForVolumeMountPointW) {
-        skip("GetVolumeNameForVolumeMountPointW not found\n");
+        win_skip("GetVolumeNameForVolumeMountPointW not found\n");
         return;
     }
 
@@ -221,8 +259,8 @@ static void test_GetLogicalDriveStringsA(void)
     UINT size, size2;
     char *buf, *ptr;
 
+    ok( pGetLogicalDriveStringsA != NULL, "GetLogicalDriveStringsA not available\n");
     if(!pGetLogicalDriveStringsA) {
-        win_skip("GetLogicalDriveStringsA not available\n");
         return;
     }
 
@@ -240,9 +278,7 @@ static void test_GetLogicalDriveStringsA(void)
     ok(size2 == size-1, "size2 = %d\n", size2);
 
     for(ptr = buf; ptr < buf+size2; ptr += 4) {
-        ok(('A' <= *ptr && *ptr <= 'Z') ||
-           (broken('a' <= *ptr && *ptr <= 'z')), /* Win9x and WinMe */
-           "device name '%c' is not uppercase\n", *ptr);
+        ok(('A' <= *ptr && *ptr <= 'Z'), "device name '%c' is not uppercase\n", *ptr);
         ok(ptr[1] == ':', "ptr[1] = %c, expected ':'\n", ptr[1]);
         ok(ptr[2] == '\\', "ptr[2] = %c expected '\\'\n", ptr[2]);
         ok(!ptr[3], "ptr[3] = %c expected nullbyte\n", ptr[3]);
@@ -257,8 +293,8 @@ static void test_GetLogicalDriveStringsW(void)
     UINT size, size2;
     WCHAR *buf, *ptr;
 
+    ok( pGetLogicalDriveStringsW != NULL, "GetLogicalDriveStringsW not available\n");
     if(!pGetLogicalDriveStringsW) {
-        win_skip("GetLogicalDriveStringsW not available\n");
         return;
     }
 
@@ -295,21 +331,17 @@ static void test_GetVolumeInformationA(void)
 {
     BOOL ret;
     UINT result;
-    char Root_Dir0[]="C:";
-    char Root_Dir1[]="C:\\";
-    char Root_Dir2[]="\\\\?\\C:\\";
+    char Root_Colon[]="C:";
+    char Root_Slash[]="C:\\";
+    char Root_UNC[]="\\\\?\\C:\\";
     char volume[MAX_PATH+1];
     DWORD vol_name_size=MAX_PATH+1, vol_serial_num=-1, max_comp_len=0, fs_flags=0, fs_name_len=MAX_PATH+1;
     char vol_name_buf[MAX_PATH+1], fs_name_buf[MAX_PATH+1];
     char windowsdir[MAX_PATH+10];
     char currentdir[MAX_PATH+1];
 
-    if (!pGetVolumeInformationA) {
-        win_skip("GetVolumeInformationA not found\n");
-        return;
-    }
-    if (!pGetVolumeNameForVolumeMountPointA) {
-        win_skip("GetVolumeNameForVolumeMountPointA not found\n");
+    ok( pGetVolumeInformationA != NULL, "GetVolumeInformationA not found\n");
+    if(!pGetVolumeInformationA) {
         return;
     }
 
@@ -317,81 +349,147 @@ static void test_GetVolumeInformationA(void)
     result = GetWindowsDirectory(windowsdir, sizeof(windowsdir));
     ok(result < sizeof(windowsdir), "windowsdir is abnormally long!\n");
     ok(result != 0, "GetWindowsDirectory: error %d\n", GetLastError());
-    Root_Dir0[0] = windowsdir[0];
-    Root_Dir1[0] = windowsdir[0];
-    Root_Dir2[4] = windowsdir[0];
-
-    /* get the unique volume name for the windows drive  */
-    ret = pGetVolumeNameForVolumeMountPointA(Root_Dir1, volume, MAX_PATH);
-    ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
+    Root_Colon[0] = windowsdir[0];
+    Root_Slash[0] = windowsdir[0];
+    Root_UNC[4] = windowsdir[0];
 
     result = GetCurrentDirectory(MAX_PATH, currentdir);
     ok(result, "GetCurrentDirectory: error %d\n", GetLastError());
+    /* Note that GetCurrentDir yields no trailing slash for subdirs */
 
-    /*  ****  now start the tests       ****  */
-    /* check for error on no trailing \   */
-    if (result > 3)
-    {
-        ret = pGetVolumeInformationA(Root_Dir0, vol_name_buf, vol_name_size, NULL,
-                NULL, NULL, fs_name_buf, fs_name_len);
-        ok(!ret && GetLastError() == ERROR_INVALID_NAME,
-            "GetVolumeInformationA w/o '\\' did not fail, last error %u\n", GetLastError());
-    }
-    else
-        skip("Running on a root directory\n");
-
-    /* check for error on no trailing \ when current dir is root dir */
-    ret = SetCurrentDirectory(Root_Dir1);
+    /* check for NO error on no trailing \ when current dir is root dir */
+    ret = SetCurrentDirectory(Root_Slash);
     ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
-    ret = pGetVolumeInformationA(Root_Dir0, vol_name_buf, vol_name_size, NULL,
+    ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
             NULL, NULL, fs_name_buf, fs_name_len);
-    todo_wine
-    ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError());
+    ok(ret, "GetVolumeInformationA root failed, last error %u\n", GetLastError());
 
-    /* check for error on no trailing \ when current dir is windows dir */
+    /* check for error on no trailing \ when current dir is subdir (windows) of queried drive */
     ret = SetCurrentDirectory(windowsdir);
     ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
-    ret = pGetVolumeInformationA(Root_Dir0, vol_name_buf, vol_name_size, NULL,
+    SetLastError(0xdeadbeef);
+    ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
             NULL, NULL, fs_name_buf, fs_name_len);
-    ok(!ret && GetLastError() == ERROR_INVALID_NAME,
-        "GetVolumeInformationA did not fail, last error %u\n", GetLastError());
+    ok(!ret && (GetLastError() == ERROR_INVALID_NAME),
+        "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
 
     /* reset current directory */
     ret = SetCurrentDirectory(currentdir);
     ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
 
+    if (toupper(currentdir[0]) == toupper(windowsdir[0])) {
+        skip("Please re-run from another device than %c:\n", windowsdir[0]);
+        /* FIXME: Use GetLogicalDrives to find another device to avoid this skip. */
+    } else {
+        char Root_Env[]="=C:"; /* where MS maintains the per volume directory */
+        Root_Env[1] = windowsdir[0];
+
+        /* C:\windows becomes the current directory on drive C: */
+        /* Note that paths to subdirs are stored without trailing slash, like what GetCurrentDir yields. */
+        ret = SetEnvironmentVariable(Root_Env, windowsdir);
+        ok(ret, "SetEnvironmentVariable %s failed\n", Root_Env);
+
+        ret = SetCurrentDirectory(windowsdir);
+        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+        ret = SetCurrentDirectory(currentdir);
+        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+
+        /* windows dir is current on the root drive, call fails */
+        SetLastError(0xdeadbeef);
+        ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
+                NULL, NULL, fs_name_buf, fs_name_len);
+        ok(!ret && (GetLastError() == ERROR_INVALID_NAME),
+           "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
+
+        /* Try normal drive letter with trailing \ */
+        ret = pGetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size, NULL,
+                NULL, NULL, fs_name_buf, fs_name_len);
+        ok(ret, "GetVolumeInformationA with \\ failed, last error %u\n", GetLastError());
+
+        ret = SetCurrentDirectory(Root_Slash);
+        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+        ret = SetCurrentDirectory(currentdir);
+        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+
+        /* windows dir is STILL CURRENT on root drive; the call fails as before,   */
+        /* proving that SetCurrentDir did not remember the other drive's directory */
+        SetLastError(0xdeadbeef);
+        ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
+                NULL, NULL, fs_name_buf, fs_name_len);
+        ok(!ret && (GetLastError() == ERROR_INVALID_NAME),
+           "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
+
+        /* Now C:\ becomes the current directory on drive C: */
+        ret = SetEnvironmentVariable(Root_Env, Root_Slash); /* set =C:=C:\ */
+        ok(ret, "SetEnvironmentVariable %s failed\n", Root_Env);
+
+        /* \ is current on root drive, call succeeds */
+        ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
+                NULL, NULL, fs_name_buf, fs_name_len);
+        ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError());
+
+        /* again, SetCurrentDirectory on another drive does not matter */
+        ret = SetCurrentDirectory(Root_Slash);
+        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+        ret = SetCurrentDirectory(currentdir);
+        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+
+        /* \ is current on root drive, call succeeds */
+        ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
+                NULL, NULL, fs_name_buf, fs_name_len);
+        ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError());
+    }
+
     /* try null root directory to return "root of the current directory"  */
     ret = pGetVolumeInformationA(NULL, vol_name_buf, vol_name_size, NULL,
             NULL, NULL, fs_name_buf, fs_name_len);
     ok(ret, "GetVolumeInformationA failed on null root dir, last error %u\n", GetLastError());
 
     /* Try normal drive letter with trailing \  */
-    ret = pGetVolumeInformationA(Root_Dir1, vol_name_buf, vol_name_size,
+    ret = pGetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size,
             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
-    ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Dir1, GetLastError());
+    ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Slash, GetLastError());
 
-    /* try again with dirve letter and the "disable parsing" prefix */
-    ret = pGetVolumeInformationA(Root_Dir2, vol_name_buf, vol_name_size,
-            &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
-    todo_wine ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Dir2, GetLastError());
-
-    /* try again with unique voluem name */
-    ret = pGetVolumeInformationA(volume, vol_name_buf, vol_name_size,
+    /* try again with drive letter and the "disable parsing" prefix */
+    SetLastError(0xdeadbeef);
+    ret = pGetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size,
             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
-    todo_wine ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", volume, GetLastError());
+    ok(ret, "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", Root_UNC, GetLastError());
 
     /* try again with device name space  */
-    Root_Dir2[2] = '.';
-    ret = pGetVolumeInformationA(Root_Dir2, vol_name_buf, vol_name_size,
+    Root_UNC[2] = '.';
+    SetLastError(0xdeadbeef);
+    ret = pGetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size,
             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
-    todo_wine ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Dir2, GetLastError());
+    ok(ret, "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", Root_UNC, GetLastError());
 
     /* try again with a directory off the root - should generate error  */
     if (windowsdir[strlen(windowsdir)-1] != '\\') strcat(windowsdir, "\\");
+    SetLastError(0xdeadbeef);
     ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size,
             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
-    todo_wine ok(!ret && GetLastError()==ERROR_DIR_NOT_ROOT,
-          "GetVolumeInformationA failed, root=%s, last error=%u\n", windowsdir, GetLastError());
+    ok(!ret && (GetLastError()==ERROR_DIR_NOT_ROOT),
+          "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError());
+    /* A subdir with trailing \ yields DIR_NOT_ROOT instead of INVALID_NAME */
+    if (windowsdir[strlen(windowsdir)-1] == '\\') windowsdir[strlen(windowsdir)-1] = 0;
+    SetLastError(0xdeadbeef);
+    ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size,
+            &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
+    ok(!ret && (GetLastError()==ERROR_INVALID_NAME),
+          "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError());
+
+    if (!pGetVolumeNameForVolumeMountPointA) {
+        win_skip("GetVolumeNameForVolumeMountPointA not found\n");
+        return;
+    }
+    /* get the unique volume name for the windows drive  */
+    ret = pGetVolumeNameForVolumeMountPointA(Root_Slash, volume, MAX_PATH);
+    ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
+
+    /* try again with unique volume name */
+    ret = pGetVolumeInformationA(volume, vol_name_buf, vol_name_size,
+            &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
+    ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", volume, GetLastError());
 }
 
 /* Test to check that unique volume name from windows dir mount point  */
@@ -427,7 +525,8 @@ static void test_enum_vols(void)
     hFind = pFindFirstVolumeA( Volume_2, MAX_PATH );
     ok(hFind != INVALID_HANDLE_VALUE, "FindFirstVolume failed, err=%u\n",
                 GetLastError());
-
+    /* ReactOS */
+    if (hFind != INVALID_HANDLE_VALUE) {
     do
     {
         /* validate correct length of unique volume name  */
@@ -440,6 +539,197 @@ static void test_enum_vols(void)
     } while (pFindNextVolumeA( hFind, Volume_2, MAX_PATH ));
     ok(found, "volume name %s not found by Find[First/Next]Volume\n", Volume_1);
     pFindVolumeClose( hFind );
+    }
+}
+
+static void test_disk_extents(void)
+{
+    BOOL ret;
+    DWORD size;
+    HANDLE handle;
+    static DWORD data[16];
+
+    handle = CreateFileA( "\\\\.\\c:", GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
+    if (handle == INVALID_HANDLE_VALUE)
+    {
+        win_skip("can't open c: drive %u\n", GetLastError());
+        return;
+    }
+    size = 0;
+    ret = DeviceIoControl( handle, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, &data,
+                           sizeof(data), &data, sizeof(data), &size, NULL );
+    if (!ret && GetLastError() == ERROR_INVALID_FUNCTION)
+    {
+        win_skip("IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS not supported\n");
+        CloseHandle( handle );
+        return;
+    }
+    ok(ret, "DeviceIoControl failed %u\n", GetLastError());
+    ok(size == 32, "expected 32, got %u\n", size);
+    CloseHandle( handle );
+}
+
+static void test_GetVolumePathNamesForVolumeNameA(void)
+{
+    BOOL ret;
+    char volume[MAX_PATH], buffer[MAX_PATH];
+    DWORD len, error;
+
+    if (!pGetVolumePathNamesForVolumeNameA || !pGetVolumeNameForVolumeMountPointA)
+    {
+        win_skip("required functions not found\n");
+        return;
+    }
+
+    ret = pGetVolumeNameForVolumeMountPointA( "c:\\", volume, sizeof(volume) );
+    ok(ret, "failed to get volume name %u\n", GetLastError());
+    trace("c:\\ -> %s\n", volume);
+
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameA( NULL, NULL, 0, NULL );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameA( "", NULL, 0, NULL );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameA( volume, NULL, 0, NULL );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", error);
+
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameA( volume, buffer, 0, NULL );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", error);
+
+    memset( buffer, 0xff, sizeof(buffer) );
+    ret = pGetVolumePathNamesForVolumeNameA( volume, buffer, sizeof(buffer), NULL );
+    ok(ret, "failed to get path names %u\n", GetLastError());
+    ok(!strcmp( "C:\\", buffer ), "expected \"\\C:\" got \"%s\"\n", buffer);
+    ok(!buffer[4], "expected double null-terminated buffer\n");
+
+    len = 0;
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameA( NULL, NULL, 0, &len );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+
+    len = 0;
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameA( NULL, NULL, sizeof(buffer), &len );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+
+    len = 0;
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameA( NULL, buffer, sizeof(buffer), &len );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+
+    len = 0;
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameA( NULL, buffer, sizeof(buffer), &len );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+
+    len = 0;
+    memset( buffer, 0xff, sizeof(buffer) );
+    ret = pGetVolumePathNamesForVolumeNameA( volume, buffer, sizeof(buffer), &len );
+    ok(ret, "failed to get path names %u\n", GetLastError());
+    ok(len == 5 || broken(len == 2), "expected 5 got %u\n", len);
+    ok(!strcmp( "C:\\", buffer ), "expected \"\\C:\" got \"%s\"\n", buffer);
+    ok(!buffer[4], "expected double null-terminated buffer\n");
+}
+
+static void test_GetVolumePathNamesForVolumeNameW(void)
+{
+    static const WCHAR empty[] = {0};
+    static const WCHAR drive_c[] = {'c',':','\\',0};
+    static const WCHAR volume_null[] = {'\\','\\','?','\\','V','o','l','u','m','e',
+        '{','0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0',
+        '-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0','}','\\',0};
+    BOOL ret;
+    WCHAR volume[MAX_PATH], buffer[MAX_PATH];
+    DWORD len, error;
+
+    if (!pGetVolumePathNamesForVolumeNameW || !pGetVolumeNameForVolumeMountPointW)
+    {
+        win_skip("required functions not found\n");
+        return;
+    }
+
+    ret = pGetVolumeNameForVolumeMountPointW( drive_c, volume, sizeof(volume)/sizeof(volume[0]) );
+    ok(ret, "failed to get volume name %u\n", GetLastError());
+
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameW( empty, NULL, 0, NULL );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameW( volume, NULL, 0, NULL );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", error);
+
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, 0, NULL );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", error);
+
+    if (0) { /* crash */
+    ret = pGetVolumePathNamesForVolumeNameW( volume, NULL, sizeof(buffer), NULL );
+    ok(ret, "failed to get path names %u\n", GetLastError());
+    }
+
+    ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, sizeof(buffer), NULL );
+    ok(ret, "failed to get path names %u\n", GetLastError());
+
+    len = 0;
+    memset( buffer, 0xff, sizeof(buffer) );
+    ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, sizeof(buffer), &len );
+    ok(ret, "failed to get path names %u\n", GetLastError());
+    ok(len == 5, "expected 5 got %u\n", len);
+    ok(!buffer[4], "expected double null-terminated buffer\n");
+
+    len = 0;
+    volume[1] = '?';
+    volume[lstrlenW( volume ) - 1] = 0;
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, sizeof(buffer), &len );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+
+    len = 0;
+    volume[0] = '\\';
+    volume[1] = 0;
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, sizeof(buffer), &len );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    todo_wine ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", error);
+
+    len = 0;
+    lstrcpyW( volume, volume_null );
+    SetLastError( 0xdeadbeef );
+    ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, sizeof(buffer), &len );
+    error = GetLastError();
+    ok(!ret, "expected failure\n");
+    ok(error == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND got %u\n", error);
 }
 
 START_TEST(volume)
@@ -453,8 +743,11 @@ START_TEST(volume)
     pGetLogicalDriveStringsA = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsA");
     pGetLogicalDriveStringsW = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsW");
     pGetVolumeInformationA = (void *) GetProcAddress(hdll, "GetVolumeInformationA");
+    pGetVolumePathNamesForVolumeNameA = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameA");
+    pGetVolumePathNamesForVolumeNameW = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameW");
 
     test_query_dos_deviceA();
+    test_define_dos_deviceA();
     test_FindFirstVolume();
     test_GetVolumeNameForVolumeMountPointA();
     test_GetVolumeNameForVolumeMountPointW();
@@ -462,4 +755,7 @@ START_TEST(volume)
     test_GetLogicalDriveStringsW();
     test_GetVolumeInformationA();
     test_enum_vols();
+    test_disk_extents();
+    test_GetVolumePathNamesForVolumeNameA();
+    test_GetVolumePathNamesForVolumeNameW();
 }