From 3aa4feb578fb1afd4a3b600c86b6eda48a3f0305 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 8 Jul 2020 14:16:21 +0200 Subject: [PATCH] mountmgr: Use wine_get_dos_file_name() instead of wine_unix_to_nt_file_name(). Signed-off-by: Alexandre Julliard --- 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 40176131ca9..f7a1f1e9b55 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 cf12f03a73b..6393dbf0221 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;