Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index ba11a121bc5..da3824b10ee 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -44,7 +44,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(rawinput);
struct device { - WCHAR *path; + SP_DEVICE_INTERFACE_DETAIL_DATA_W *detail; HANDLE file; RID_DEVICE_INFO info; PHIDP_PREPARSED_DATA data; @@ -94,7 +94,6 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) SP_DEVICE_INTERFACE_DETAIL_DATA_W *detail; struct device *device; HANDLE file; - WCHAR *path; DWORD size;
SetupDiGetDeviceInterfaceDetailW(set, iface, NULL, 0, &size, NULL); @@ -113,20 +112,12 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface)
TRACE("Found HID device %s.\n", debugstr_w(detail->DevicePath));
- if (!(path = heap_strdupW(detail->DevicePath))) - { - ERR("Failed to allocate memory.\n"); - heap_free(detail); - return NULL; - } - heap_free(detail); - - file = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, + file = CreateFileW(detail->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); if (file == INVALID_HANDLE_VALUE) { - ERR("Failed to open device file %s, error %u.\n", debugstr_w(path), GetLastError()); - heap_free(path); + ERR("Failed to open device file %s, error %u.\n", debugstr_w(detail->DevicePath), GetLastError()); + heap_free(detail); return NULL; }
@@ -135,12 +126,12 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) { ERR("Failed to allocate memory.\n"); CloseHandle(file); - heap_free(path); + heap_free(detail); return NULL; }
device = &rawinput_devices[rawinput_devices_count++]; - device->path = path; + device->detail = detail; device->file = file; device->info.cbSize = sizeof(RID_DEVICE_INFO);
@@ -171,7 +162,7 @@ static void find_devices(void) for (idx = 0; idx < rawinput_devices_count; ++idx) { CloseHandle(rawinput_devices[idx].file); - heap_free(rawinput_devices[idx].path); + heap_free(rawinput_devices[idx].detail); } rawinput_devices_count = 0;
@@ -681,8 +672,8 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT } else { - *data_size = lstrlenW(device->path) + 1; - to_copy = device->path; + *data_size = lstrlenW(device->detail->DevicePath) + 1; + to_copy = device->detail->DevicePath; } to_copy_bytes = *data_size * sizeof(WCHAR); break;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index da3824b10ee..02cdcd87820 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -80,8 +80,8 @@ static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int if (new_capacity < count) new_capacity = max_capacity;
- if (!(new_elements = heap_realloc(*elements, new_capacity * size))) - return FALSE; + if (!*elements) new_elements = malloc(new_capacity * size); + else new_elements = realloc(*elements, new_capacity * size);
*elements = new_elements; *capacity = new_capacity; @@ -102,7 +102,7 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) ERR("Failed to get device path, error %#x.\n", GetLastError()); return FALSE; } - if (!(detail = heap_alloc(size))) + if (!(detail = malloc(size))) { ERR("Failed to allocate memory.\n"); return FALSE; @@ -117,7 +117,7 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) if (file == INVALID_HANDLE_VALUE) { ERR("Failed to open device file %s, error %u.\n", debugstr_w(detail->DevicePath), GetLastError()); - heap_free(detail); + free(detail); return NULL; }
@@ -126,7 +126,7 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) { ERR("Failed to allocate memory.\n"); CloseHandle(file); - heap_free(detail); + free(detail); return NULL; }
@@ -162,7 +162,7 @@ static void find_devices(void) for (idx = 0; idx < rawinput_devices_count; ++idx) { CloseHandle(rawinput_devices[idx].file); - heap_free(rawinput_devices[idx].detail); + free(rawinput_devices[idx].detail); } rawinput_devices_count = 0;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=88855
Your paranoid android.
=== debiant2 (32 bit WoW report) ===
user32: win.c:10100: Test failed: GetActiveWindow() = 00000000 win.c:10100: Test failed: GetFocus() = 00000000 win.c:10102: Test failed: Expected foreground window 000E013E, got 00E10102 win.c:10105: Test failed: Received WM_ACTIVATEAPP(0), did not expect it. win.c:10112: Test failed: Expected foreground window 000E013E, got 00000000 win.c:10114: Test failed: GetActiveWindow() = 00000000 win.c:10114: Test failed: GetFocus() = 00000000 win.c:10122: Test failed: Received WM_ACTIVATEAPP(1), did not expect it.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 02cdcd87820..bd204765700 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -134,6 +134,7 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface) device->detail = detail; device->file = file; device->info.cbSize = sizeof(RID_DEVICE_INFO); + device->data = NULL;
return device; } @@ -161,6 +162,7 @@ static void find_devices(void) /* destroy previous list */ for (idx = 0; idx < rawinput_devices_count; ++idx) { + HidD_FreePreparsedData(rawinput_devices[idx].data); CloseHandle(rawinput_devices[idx].file); free(rawinput_devices[idx].detail); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=88856
Your paranoid android.
=== debiant2 (32 bit Chinese:China report) ===
user32: clipboard.c:760: Test failed: 1: gle 5 clipboard.c:765: Test failed: 1.0: got 0000 instead of 0007 clipboard.c:805: Test failed: 1: gle 1418 clipboard.c:815: Test failed: 1: count 4 clipboard.c:818: Test failed: 1: gle 1418 clipboard.c:852: Test failed: 1: format 0007 got data 00BD8F20 clipboard.c:853: Test failed: 1.0: formats 00000000 have been rendered clipboard.c:858: Test failed: 1.0: formats 00000000 have been rendered clipboard.c:852: Test failed: 1: format 0001 got data 00BD8418 clipboard.c:853: Test failed: 1.2: formats 00000000 have been rendered clipboard.c:858: Test failed: 1.2: formats 00000000 have been rendered clipboard.c:852: Test failed: 1: format 000d got data 00BD8F50 clipboard.c:853: Test failed: 1.3: formats 00000000 have been rendered clipboard.c:858: Test failed: 1.3: formats 00000000 have been rendered
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index bd204765700..bf60e8bfb15 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -674,7 +674,7 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT } else { - *data_size = lstrlenW(device->detail->DevicePath) + 1; + *data_size = wcslen(device->detail->DevicePath) + 1; to_copy = device->detail->DevicePath; } to_copy_bytes = *data_size * sizeof(WCHAR);