Alexandre Goujon ale.goujon@gmail.com writes:
Previous approach was patch #88280
dlls/kernel32/volume.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c index 8377e41..57453bb 100644 --- a/dlls/kernel32/volume.c +++ b/dlls/kernel32/volume.c @@ -1435,27 +1435,15 @@ DWORD WINAPI QueryDosDeviceA( LPCSTR devname, LPSTR target, DWORD bufsize ) */ DWORD WINAPI GetLogicalDrives(void) {
- const char *config_dir = wine_get_config_dir();
- struct stat st;
- char *buffer, *dev; DWORD ret = 0;
- WCHAR drive; int i;
- if (!(buffer = HeapAlloc( GetProcessHeap(), 0, strlen(config_dir) + sizeof("/dosdevices/a:") )))
- {
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return 0;
- }
- strcpy( buffer, config_dir );
- strcat( buffer, "/dosdevices/a:" );
- dev = buffer + strlen(buffer) - 2;
- for (i = 0; i < 26; i++) {
*dev = 'a' + i;
if (!stat( buffer, &st )) ret |= (1 << i);
drive = 'A'+i;
}if (get_mountmgr_drive_type(&drive) != DRIVE_UNKNOWN) ret |= (1 << i);
That's very inefficient. There are better way of enumerating drives, check for instance QueryDosDevice.
On 07/23/2012 03:03 PM, Alexandre Julliard wrote:
That's very inefficient. There are better way of enumerating drives, check for instance QueryDosDevice.
I'm not sure QueryDosDevice is more efficient : + with NULL device name, it returns every MS-DOS device which is not what we want + if we call it with A: B: C: and so on, we still need a loop + plus, we have to dynamically increase the buffer size while GetLastError is ERROR_INSUFFICIENT_BUFFER
Would creating a new IOCTL_MOUNTMGR_QUERY_ALL_UNIX_DRIVES be (more) acceptable ?
GOUJON Alexandre ale.goujon@gmail.com writes:
On 07/23/2012 03:03 PM, Alexandre Julliard wrote:
That's very inefficient. There are better way of enumerating drives, check for instance QueryDosDevice.
I'm not sure QueryDosDevice is more efficient :
- with NULL device name, it returns every MS-DOS device which is not
what we want
It's pretty much what we want. Check how it does it.
On 07/23/2012 09:15 PM, Alexandre Julliard wrote:
GOUJON Alexandre ale.goujon@gmail.com writes:
On 07/23/2012 03:03 PM, Alexandre Julliard wrote:
That's very inefficient. There are better way of enumerating drives, check for instance QueryDosDevice.
I'm not sure QueryDosDevice is more efficient :
- with NULL device name, it returns every MS-DOS device which is not
what we want
It's pretty much what we want. Check how it does it.
I may be mis-using it but on my (virtualized) Win7, QueryDosDevice with a NULL argument returns 6651 chars. I truncated the output to the first strings and here's the result :
Z: Global D: ACPI#PNP0C0A#0#{72631e54-78a4-11d0-bcf7-00aa00b7b32a} PhysicalDrive0 DISPLAY5 Root#MS_L2TPMINIPORT#0000#{cac88484-7515-4c03-82e6-71a87abac361} VDRVROOT STORAGE#Volume#{a76e80e3-477f-11e1-b83a-806e6f6e6963}#0000000006500000#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b} SW#{eeab7790-c514-11d1-b42b-00805fc1270e}#asyncmac#{cac88484-7515-4c03-82e6-71a87abac361} Root#SYSTEM#0000#{97ebaacb-95bd-11d0-a3ea-00a0c9223196} DISPLAY1 Root#MS_SSTPMINIPORT#0000#{cac88484-7515-4c03-82e6-71a87abac361}
And note that using NULL, the strings are concatenated. So getting each string is not very easy.
But if you say, it's the way to go .. will do that.
GOUJON Alexandre ale.goujon@gmail.com writes:
I may be mis-using it but on my (virtualized) Win7, QueryDosDevice with a NULL argument returns 6651 chars. I truncated the output to the first strings and here's the result :
Z: Global D: ACPI#PNP0C0A#0#{72631e54-78a4-11d0-bcf7-00aa00b7b32a} PhysicalDrive0 DISPLAY5 Root#MS_L2TPMINIPORT#0000#{cac88484-7515-4c03-82e6-71a87abac361} VDRVROOT STORAGE#Volume#{a76e80e3-477f-11e1-b83a-806e6f6e6963}#0000000006500000#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b} SW#{eeab7790-c514-11d1-b42b-00805fc1270e}#asyncmac#{cac88484-7515-4c03-82e6-71a87abac361} Root#SYSTEM#0000#{97ebaacb-95bd-11d0-a3ea-00a0c9223196} DISPLAY1 Root#MS_SSTPMINIPORT#0000#{cac88484-7515-4c03-82e6-71a87abac361}
And note that using NULL, the strings are concatenated. So getting each string is not very easy.
It's actually very easy, but you don't even need that. Look at how QueryDosDevice is implemented and think about it some more.