Commit d05b88dd authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

user32: Map DEV_BROADCAST_DEVICEINTERFACE to ANSI for registered device notifications.

parent 98336958
......@@ -1400,7 +1400,7 @@ static LRESULT WINAPI device_notify_proc(HWND window, UINT message, WPARAM wpara
if (IsEqualGUID(&iface->dbcc_classguid, &bus_class))
{
++got_bus_arrival;
todo_wine ok(!strcmp(iface->dbcc_name, "\\\\?\\ROOT#WINETEST#0#{deadbeef-29ef-4538-a5fd-b69573a362c1}"),
ok(!strcmp(iface->dbcc_name, "\\\\?\\ROOT#WINETEST#0#{deadbeef-29ef-4538-a5fd-b69573a362c1}"),
"got name %s\n", debugstr_a(iface->dbcc_name));
}
else if (IsEqualGUID(&iface->dbcc_classguid, &child_class))
......@@ -1428,7 +1428,7 @@ static LRESULT WINAPI device_notify_proc(HWND window, UINT message, WPARAM wpara
if (IsEqualGUID(&iface->dbcc_classguid, &bus_class))
{
++got_bus_removal;
todo_wine ok(!strcmp(iface->dbcc_name, "\\\\?\\ROOT#WINETEST#0#{deadbeef-29ef-4538-a5fd-b69573a362c1}"),
ok(!strcmp(iface->dbcc_name, "\\\\?\\ROOT#WINETEST#0#{deadbeef-29ef-4538-a5fd-b69573a362c1}"),
"got name %s\n", debugstr_a(iface->dbcc_name));
}
else if (IsEqualGUID(&iface->dbcc_classguid, &child_class))
......
......@@ -495,12 +495,52 @@ BOOL WINAPI UnloadKeyboardLayout( HKL layout )
}
static DWORD CALLBACK devnotify_window_callback(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header)
static DWORD CALLBACK devnotify_window_callbackW(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header)
{
SendMessageTimeoutW(handle, WM_DEVICECHANGE, flags, (LPARAM)header, SMTO_ABORTIFHUNG, 2000, NULL);
return 0;
}
static DWORD CALLBACK devnotify_window_callbackA(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header)
{
if (flags & 0x8000)
{
switch (header->dbch_devicetype)
{
case DBT_DEVTYP_DEVICEINTERFACE:
{
const DEV_BROADCAST_DEVICEINTERFACE_W *ifaceW = (const DEV_BROADCAST_DEVICEINTERFACE_W *)header;
size_t lenW = wcslen( ifaceW->dbcc_name );
DEV_BROADCAST_DEVICEINTERFACE_A *ifaceA;
DWORD lenA;
if (!(ifaceA = malloc( offsetof(DEV_BROADCAST_DEVICEINTERFACE_A, dbcc_name[lenW * 3 + 1]) )))
return 0;
lenA = WideCharToMultiByte( CP_ACP, 0, ifaceW->dbcc_name, lenW + 1,
ifaceA->dbcc_name, lenW * 3 + 1, NULL, NULL );
ifaceA->dbcc_size = offsetof(DEV_BROADCAST_DEVICEINTERFACE_A, dbcc_name[lenA + 1]);
ifaceA->dbcc_devicetype = ifaceW->dbcc_devicetype;
ifaceA->dbcc_reserved = ifaceW->dbcc_reserved;
ifaceA->dbcc_classguid = ifaceW->dbcc_classguid;
SendMessageTimeoutA( handle, WM_DEVICECHANGE, flags, (LPARAM)ifaceA, SMTO_ABORTIFHUNG, 2000, NULL );
free( ifaceA );
return 0;
}
default:
FIXME( "unimplemented W to A mapping for %#lx\n", header->dbch_devicetype );
/* fall through */
case DBT_DEVTYP_HANDLE:
case DBT_DEVTYP_OEM:
break;
}
}
SendMessageTimeoutA( handle, WM_DEVICECHANGE, flags, (LPARAM)header, SMTO_ABORTIFHUNG, 2000, NULL );
return 0;
}
static DWORD CALLBACK devnotify_service_callback(HANDLE handle, DWORD flags, DEV_BROADCAST_HDR *header)
{
FIXME("Support for service handles is not yet implemented!\n");
......@@ -580,8 +620,10 @@ HDEVNOTIFY WINAPI RegisterDeviceNotificationW( HANDLE handle, void *filter, DWOR
if (flags & DEVICE_NOTIFY_SERVICE_HANDLE)
details.cb = devnotify_service_callback;
else if (IsWindowUnicode( handle ))
details.cb = devnotify_window_callbackW;
else
details.cb = devnotify_window_callback;
details.cb = devnotify_window_callbackA;
return I_ScRegisterDeviceNotification( &details, filter, 0 );
}
......
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