Commit 5d63f809 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

user32: Store the device path as a simple string pointer.

parent 58571710
...@@ -46,7 +46,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(rawinput); ...@@ -46,7 +46,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(rawinput);
struct device struct device
{ {
SP_DEVICE_INTERFACE_DETAIL_DATA_W *detail; WCHAR *path;
HANDLE file; HANDLE file;
HANDLE handle; HANDLE handle;
RID_DEVICE_INFO info; RID_DEVICE_INFO info;
...@@ -103,11 +103,11 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface, ...@@ -103,11 +103,11 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface,
struct device *device = NULL; struct device *device = NULL;
RID_DEVICE_INFO info; RID_DEVICE_INFO info;
IO_STATUS_BLOCK io; IO_STATUS_BLOCK io;
WCHAR *path, *pos;
NTSTATUS status; NTSTATUS status;
UINT32 handle; UINT32 handle;
DWORD i, size; DWORD i, size;
HANDLE file; HANDLE file;
WCHAR *pos;
SetupDiGetDeviceInterfaceDetailW(set, iface, NULL, 0, &size, &device_data); SetupDiGetDeviceInterfaceDetailW(set, iface, NULL, 0, &size, &device_data);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
...@@ -123,16 +123,19 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface, ...@@ -123,16 +123,19 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface,
} }
detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W); detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
SetupDiGetDeviceInterfaceDetailW(set, iface, detail, size, NULL, NULL); SetupDiGetDeviceInterfaceDetailW(set, iface, detail, size, NULL, NULL);
path = wcsdup( detail->DevicePath );
free( detail );
if (!path) return NULL;
/* upper case everything but the GUID */ /* upper case everything but the GUID */
for (pos = detail->DevicePath; *pos && *pos != '{'; pos++) *pos = towupper(*pos); for (pos = path; *pos && *pos != '{'; pos++) *pos = towupper(*pos);
file = CreateFileW(detail->DevicePath, GENERIC_READ | GENERIC_WRITE, file = CreateFileW( path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
if (file == INVALID_HANDLE_VALUE) if (file == INVALID_HANDLE_VALUE)
{ {
ERR("Failed to open device file %s, error %lu.\n", debugstr_w(detail->DevicePath), GetLastError()); ERR( "Failed to open device file %s, error %lu.\n", debugstr_w(path), GetLastError() );
free(detail); free( path );
return NULL; return NULL;
} }
...@@ -199,16 +202,16 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface, ...@@ -199,16 +202,16 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface,
if (device) if (device)
{ {
TRACE("Updating device %x / %s.\n", handle, debugstr_w(detail->DevicePath)); TRACE( "Updating device %#x / %s.\n", handle, debugstr_w(path) );
free(device->data); free(device->data);
CloseHandle(device->file); CloseHandle(device->file);
free(device->detail); free( device->path );
} }
else if (array_reserve((void **)&rawinput_devices, &rawinput_devices_max, else if (array_reserve((void **)&rawinput_devices, &rawinput_devices_max,
rawinput_devices_count + 1, sizeof(*rawinput_devices))) rawinput_devices_count + 1, sizeof(*rawinput_devices)))
{ {
device = &rawinput_devices[rawinput_devices_count++]; device = &rawinput_devices[rawinput_devices_count++];
TRACE("Adding device %x / %s.\n", handle, debugstr_w(detail->DevicePath)); TRACE( "Adding device %#x / %s.\n", handle, debugstr_w(path) );
} }
else else
{ {
...@@ -216,7 +219,7 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface, ...@@ -216,7 +219,7 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface,
goto fail; goto fail;
} }
device->detail = detail; device->path = path;
device->file = file; device->file = file;
device->handle = ULongToHandle(handle); device->handle = ULongToHandle(handle);
device->info = info; device->info = info;
...@@ -227,7 +230,7 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface, ...@@ -227,7 +230,7 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface,
fail: fail:
free( preparsed ); free( preparsed );
CloseHandle( file ); CloseHandle( file );
free( detail ); free( path );
return NULL; return NULL;
} }
...@@ -258,7 +261,7 @@ void rawinput_update_device_list(void) ...@@ -258,7 +261,7 @@ void rawinput_update_device_list(void)
{ {
free(rawinput_devices[idx].data); free(rawinput_devices[idx].data);
CloseHandle(rawinput_devices[idx].file); CloseHandle(rawinput_devices[idx].file);
free(rawinput_devices[idx].detail); free( rawinput_devices[idx].path );
} }
rawinput_devices_count = 0; rawinput_devices_count = 0;
...@@ -762,8 +765,8 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT ...@@ -762,8 +765,8 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT
switch (command) switch (command)
{ {
case RIDI_DEVICENAME: case RIDI_DEVICENAME:
if ((len = wcslen(device->detail->DevicePath) + 1) <= data_len && data) if ((len = wcslen( device->path ) + 1) <= data_len && data)
memcpy(data, device->detail->DevicePath, len * sizeof(WCHAR)); memcpy( data, device->path, len * sizeof(WCHAR) );
*data_size = len; *data_size = len;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment