From: Vibhav Pant vibhavp@gmail.com
--- dlls/dinput/tests/hotplug.c | 6 ++--- dlls/ntoskrnl.exe/pnp.c | 44 +++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/dlls/dinput/tests/hotplug.c b/dlls/dinput/tests/hotplug.c index 44fba60d4af..f7199d2b17e 100644 --- a/dlls/dinput/tests/hotplug.c +++ b/dlls/dinput/tests/hotplug.c @@ -291,11 +291,10 @@ static LRESULT CALLBACK devnotify_wndproc( HWND hwnd, UINT msg, WPARAM wparam, L
if (device_change_expect_custom) { - todo_wine + todo_wine_if( device_change_expect_custom == 1 ) ok( header->dbch_devicetype == DBT_DEVTYP_HANDLE || broken( device_change_expect_custom == 1 && header->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE ), /* w8 32bit */ "got type %#lx\n", header->dbch_devicetype); - todo_wine_if( device_change_expect_custom > 1 ) ok( wparam == (device_change_expect_custom > 1 ? DBT_CUSTOMEVENT : DBT_DEVICEREMOVECOMPLETE), "got wparam %#Ix\n", wparam ); } @@ -611,13 +610,12 @@ static void test_RegisterDeviceNotification(void) { ret = sync_ioctl( file, IOCTL_WINETEST_DEVICE_CHANGE, (BYTE *)&device_change_events[i].notif, device_change_events[i].notif.Size, NULL, 0, 5000 ); - todo_wine ok( ret, "IOCTL_WINETEST_DEVICE_CHANGE failed, last error %lu\n", GetLastError() ); + ok( ret, "IOCTL_WINETEST_DEVICE_CHANGE failed, last error %lu\n", GetLastError() ); device_change_expect_custom++; } device_change_expect_custom++; /* extra DBT_DEVICEREMOVECOMPLETE event that is sent when device is removed */
CloseHandle( file ); - if (!ret) SetEvent( stop_event ); } if (device_change_count == 1 && device_change_expect_custom == 1) SetEvent( stop_event ); } diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c index de9c319c20f..db8285824da 100644 --- a/dlls/ntoskrnl.exe/pnp.c +++ b/dlls/ntoskrnl.exe/pnp.c @@ -1006,8 +1006,40 @@ NTSTATUS WINAPI IoRegisterDeviceInterface(DEVICE_OBJECT *device, const GUID *cla */ NTSTATUS WINAPI IoReportTargetDeviceChange( DEVICE_OBJECT *device, void *data ) { - FIXME( "(%p, %p) stub!\n", device, data ); - return STATUS_NOT_SUPPORTED; + TARGET_DEVICE_CUSTOM_NOTIFICATION *notification = data; + OBJECT_NAME_INFORMATION *name_info; + DEV_BROADCAST_HANDLE *event_handle; + DWORD size, data_size; + NTSTATUS ret; + + TRACE( "(%p, %p)\n", device, data ); + + if (notification->Version != 1) return STATUS_INVALID_PARAMETER; + + ret = ObQueryNameString( device, NULL, 0, &size ); + if (ret != STATUS_INFO_LENGTH_MISMATCH) return ret; + if (!(name_info = heap_alloc( size ))) return STATUS_NO_MEMORY; + ret = ObQueryNameString( device, name_info, size, &size ); + if (ret != STATUS_SUCCESS) return ret; + + data_size = notification->Size - offsetof( TARGET_DEVICE_CUSTOM_NOTIFICATION, CustomDataBuffer ); + size = offsetof( DEV_BROADCAST_HANDLE, dbch_data[data_size + 2 * sizeof(WCHAR)] ); + if (!(event_handle = heap_alloc_zero( size ))) + { + heap_free( name_info ); + return STATUS_NO_MEMORY; + } + + event_handle->dbch_size = size; + event_handle->dbch_devicetype = DBT_DEVTYP_HANDLE; + event_handle->dbch_eventguid = notification->Event; + event_handle->dbch_nameoffset = notification->NameBufferOffset; + memcpy( event_handle->dbch_data, notification->CustomDataBuffer, data_size ); + send_devicechange( name_info->Name.Buffer, DBT_CUSTOMEVENT, (BYTE *)event_handle, event_handle->dbch_size ); + heap_free( event_handle ); + heap_free( name_info ); + + return STATUS_SUCCESS; }
/*********************************************************************** @@ -1016,8 +1048,12 @@ NTSTATUS WINAPI IoReportTargetDeviceChange( DEVICE_OBJECT *device, void *data ) NTSTATUS WINAPI IoReportTargetDeviceChangeAsynchronous( DEVICE_OBJECT *device, void *data, PDEVICE_CHANGE_COMPLETE_CALLBACK callback, void *context ) { - FIXME( "(%p, %p, %p, %p) stub!\n", device, data, callback, context ); - return STATUS_NOT_SUPPORTED; + NTSTATUS status; + + TRACE( "(%p, %p, %p, %p) semi-stub!\n", device, data, callback, context ); + + if (!(status = IoReportTargetDeviceChange( device, data ))) callback( context ); + return status; }
/***********************************************************************