mountmgr: Use wine_get_dos_file_name() instead of wine_unix_to_nt_file_name().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-07-08 14:16:21 +02:00
parent f8699c0a71
commit 3aa4feb578
2 changed files with 19 additions and 22 deletions

View File

@ -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;
}

View File

@ -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;