[PATCH][kernel32.dll] quick and dirty implementation of GetVolumePathNamesForVolumeNameA

Tuomo Mattila tuomom at ee.oulu.fi
Tue Jun 29 18:24:33 CDT 2010


A quick and dirty implementation of function GetVolumePathNamesForVolumeNameA missing from kernel32.dll. Fixes a crash in Beat Hazard.
---

 dlls/kernel32/kernel32.spec |    2 +-
 dlls/kernel32/volume.c      |   50 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index dbcb179..9a40399 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -670,7 +670,7 @@
 @ stdcall GetVolumeNameForVolumeMountPointW(wstr ptr long)
 @ stdcall GetVolumePathNameA(str ptr long)
 @ stdcall GetVolumePathNameW(wstr ptr long)
-# @ stub GetVolumePathNamesForVolumeNameA
+@ stdcall GetVolumePathNamesForVolumeNameA(str ptr long ptr)
 @ stdcall GetVolumePathNamesForVolumeNameW(wstr ptr long ptr)
 @ stdcall GetWindowsDirectoryA(ptr long)
 @ stdcall GetWindowsDirectoryW(ptr long)
diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c
index 7596864..eb40c7e 100644
--- a/dlls/kernel32/volume.c
+++ b/dlls/kernel32/volume.c
@@ -1566,6 +1566,56 @@ BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD bu
 }
 
 /***********************************************************************
+ *           GetVolumePathNamesForVolumeNameA   (KERNEL32.@)
+ */
+BOOL WINAPI GetVolumePathNamesForVolumeNameA(LPCSTR volumename, LPSTR volumepathname, DWORD buflen, PDWORD returnlen)
+{
+
+    DWORD available_drives = GetLogicalDrives();
+    char letter;
+    int count = 0;
+    char volumename2string[50];
+    LPSTR volumename2 = volumename2string;
+    char pstr[4] = {'A', ':', '\\', 0};
+    LPCSTR pathstring = pstr;
+
+
+    FIXME("(%s, %p, %d, %p), stub!\n", debugstr_a(volumename), volumepathname, buflen, returnlen);
+
+    memset(volumepathname, 0, buflen);
+    for (letter='A'; letter<='Z'; letter++)
+    {
+        memset(volumename2string, 0, sizeof(volumename2string));
+        if (available_drives && (1<<(letter-'A')))
+            {
+                pstr[0] = letter;
+                if( (GetVolumeNameForVolumeMountPointA(pathstring, volumename2, 50)) && (!strncmp(volumename, volumename2, 50)))
+                //if getvolumename... succeeds and the names match
+                    {
+                            if ((count+4) <= (buflen-1)) //don't append the string if we don't have enough buffer space
+                            {
+                                snprintf(&volumepathname[count], 4, "%c:\\", letter);
+                                volumepathname[count+3] = 0;
+                            }
+                            count += 4;
+                    }
+
+            }
+
+    }
+    *returnlen = count;
+    if (count > (buflen-1))
+    {
+        SetLastError(ERROR_MORE_DATA);
+        return FALSE;
+    }
+    if (count == 0)
+        return FALSE;
+
+    return TRUE;
+}
+
+/***********************************************************************
  *           GetVolumePathNamesForVolumeNameW   (KERNEL32.@)
  */
 BOOL WINAPI GetVolumePathNamesForVolumeNameW(LPCWSTR volumename, LPWSTR volumepathname, DWORD buflen, PDWORD returnlen)
-- 
1.7.1




More information about the wine-patches mailing list