Module: wine Branch: master Commit: 3aa4feb578fb1afd4a3b600c86b6eda48a3f0305 URL: https://source.winehq.org/git/wine.git/?a=commit;h=3aa4feb578fb1afd4a3b600c8...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Jul 8 14:16:21 2020 +0200
mountmgr: Use wine_get_dos_file_name() instead of wine_unix_to_nt_file_name().
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mountmgr.sys/device.c | 22 ++++++++-------------- dlls/mountmgr.sys/mountmgr.c | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c index 40176131ca..f7a1f1e9b5 100644 --- a/dlls/mountmgr.sys/device.c +++ b/dlls/mountmgr.sys/device.c @@ -1017,32 +1017,26 @@ static struct volume *find_matching_volume( const char *udi, const char *device, static BOOL get_volume_device_info( struct volume *volume ) { const char *unix_device = volume->device->unix_device; - ANSI_STRING unix_name; - UNICODE_STRING nt_name; - OBJECT_ATTRIBUTES attr; + WCHAR *name; HANDLE handle; - NTSTATUS ret; CDROM_TOC toc; DWORD size; BYTE superblock[SUPERBLOCK_SIZE]; - IO_STATUS_BLOCK io;
if (!unix_device) return FALSE;
- RtlInitAnsiString( &unix_name, unix_device ); - if ((ret = wine_unix_to_nt_file_name( &unix_name, &nt_name ))) + if (!(name = wine_get_dos_file_name( unix_device ))) { - ERR("Failed to convert %s to NT, status %#x\n", debugstr_a(unix_device), ret); + ERR("Failed to convert %s to NT, err %u\n", debugstr_a(unix_device), GetLastError()); return FALSE; } - - InitializeObjectAttributes( &attr, &nt_name, OBJ_CASE_INSENSITIVE, 0, NULL ); - if ((ret = NtOpenFile( &handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ | FILE_SHARE_WRITE, - FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT ))) + handle = CreateFileW( name, GENERIC_READ | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, 0, 0 ); + RtlFreeHeap( GetProcessHeap(), 0, name ); + if (handle == INVALID_HANDLE_VALUE) { - WARN("Failed to open %s, status %#x\n", debugstr_a(unix_device), ret); - RtlFreeUnicodeString( &nt_name ); + WARN("Failed to open %s, err %u\n", debugstr_a(unix_device), GetLastError()); return FALSE; }
diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c index cf12f03a73..6393dbf022 100644 --- a/dlls/mountmgr.sys/mountmgr.c +++ b/dlls/mountmgr.sys/mountmgr.c @@ -432,7 +432,7 @@ static void WINAPI query_symbol_file( TP_CALLBACK_INSTANCE *instance, void *cont IRP *irp = context; MOUNTMGR_TARGET_NAME *result; CFStringRef query_cfstring; - WCHAR *unix_buf = NULL; + WCHAR *filename, *unix_buf = NULL; ANSI_STRING unix_path; UNICODE_STRING path; MDQueryRef mdquery; @@ -489,16 +489,19 @@ static void WINAPI query_symbol_file( TP_CALLBACK_INSTANCE *instance, void *cont HeapFree( GetProcessHeap(), 0, unix_buf ); if (status) goto done;
- status = wine_unix_to_nt_file_name( &unix_path, &path ); + filename = wine_get_dos_file_name( unix_path.Buffer ); RtlFreeAnsiString( &unix_path ); - if (status) goto done; - + if (!filename) + { + status = STATUS_NO_SUCH_FILE; + goto done; + } result = irp->AssociatedIrp.SystemBuffer; - result->DeviceNameLength = path.Length; - size = FIELD_OFFSET(MOUNTMGR_TARGET_NAME, DeviceName[path.Length / sizeof(WCHAR)]); + result->DeviceNameLength = lstrlenW(filename) * sizeof(WCHAR); + size = FIELD_OFFSET(MOUNTMGR_TARGET_NAME, DeviceName[lstrlenW(filename)]); if (size <= IoGetCurrentIrpStackLocation(irp)->Parameters.DeviceIoControl.OutputBufferLength) { - memcpy( result->DeviceName, path.Buffer, path.Length ); + memcpy( result->DeviceName, filename, lstrlenW(filename) * sizeof(WCHAR) ); irp->IoStatus.Information = size; status = STATUS_SUCCESS; } @@ -507,7 +510,7 @@ static void WINAPI query_symbol_file( TP_CALLBACK_INSTANCE *instance, void *cont irp->IoStatus.Information = sizeof(*result); status = STATUS_BUFFER_OVERFLOW; } - RtlFreeUnicodeString( &path ); + RtlFreeHeap( GetProcessHeap(), 0, filename );
done: irp->IoStatus.u.Status = status;