[User32] Implement Device Event Message handler

Need a way to send WM_DEVICECHANGE from the Service manager application.
Next step is to process it in the Client/Server Run-time Subsystem.
See CORE-16492.
This commit is contained in:
James Tabor 2020-04-11 17:41:26 -05:00
parent 152265729b
commit 1e0bb66452
3 changed files with 59 additions and 4 deletions

View file

@ -87,6 +87,14 @@ typedef struct _USER_CREATE_SYSTEM_THREAD
BOOL bRemote;
} USER_CREATE_SYSTEM_THREAD, *PUSER_CREATE_SYSTEM_THREAD;
typedef struct _USER_DEVICE_EVENT_MSG {
HWND hwnd;
WPARAM wParam;
LPARAM lParam;
DWORD Data;
ULONG_PTR Result;
} USER_DEVICE_EVENT_MSG, *PUSER_DEVICE_EVENT_MSG;
typedef struct _USER_API_MESSAGE
{
PORT_MESSAGE Header;
@ -104,6 +112,7 @@ typedef struct _USER_API_MESSAGE
USER_REGISTER_SERVICES_PROCESS RegisterServicesProcessRequest;
USER_REGISTER_LOGON_PROCESS RegisterLogonProcessRequest;
USER_CREATE_SYSTEM_THREAD CreateSystemThreadRequest;
USER_DEVICE_EVENT_MSG DeviceEventMsg;
} Data;
} USER_API_MESSAGE, *PUSER_API_MESSAGE;

View file

@ -51,6 +51,7 @@
/* CSRSS Header */
#include <csr/csr.h>
#include <win/winmsg.h>
#include <psdk/dbt.h>
/* WINE Headers */
#include <wine/unicode.h>

View file

@ -508,12 +508,57 @@ DestroyReasons(PVOID Pointer)
return FALSE;
}
BOOL
NTSTATUS
WINAPI
DeviceEventWorker(DWORD dw1, DWORD dw2, DWORD dw3, DWORD dw4, DWORD dw5)
DeviceEventWorker(HWND hwnd, WPARAM wParam, LPARAM lParam, DWORD Data, ULONG_PTR *uResult)
{
UNIMPLEMENTED;
return FALSE;
USER_API_MESSAGE ApiMessage;
PUSER_DEVICE_EVENT_MSG pusem = &ApiMessage.Data.DeviceEventMsg;
pusem->hwnd = hwnd;
pusem->wParam = wParam;
pusem->lParam = lParam;
pusem->Data = Data;
pusem->Result = 0;
TRACE("DeviceEventWorker : hwnd %p, wParam %d, lParam %d, Data %d, uResult %p\n", hwnd, wParam, lParam, Data, uResult);
if ( lParam == 0 )
{
CsrClientCallServer( (PCSR_API_MESSAGE)&ApiMessage,
NULL,
CSR_CREATE_API_NUMBER( USERSRV_SERVERDLL_INDEX, UserpDeviceEvent ),
sizeof(*pusem) );
}
else
{
PCSR_CAPTURE_BUFFER pcsrcb = NULL;
PDEV_BROADCAST_HDR pdev_br = (PDEV_BROADCAST_HDR)lParam;
ULONG BufferSize = pdev_br->dbch_size;
pcsrcb = CsrAllocateCaptureBuffer( 1, BufferSize );
if ( !pcsrcb )
{
return STATUS_NO_MEMORY;
}
CsrCaptureMessageBuffer( pcsrcb, (PVOID)lParam, BufferSize, (PVOID*)&pusem->lParam );
CsrClientCallServer( (PCSR_API_MESSAGE)&ApiMessage,
pcsrcb,
CSR_CREATE_API_NUMBER( USERSRV_SERVERDLL_INDEX, UserpDeviceEvent ),
sizeof(*pusem) );
CsrFreeCaptureBuffer( pcsrcb );
}
if (NT_SUCCESS(ApiMessage.Status))
{
*uResult = pusem->Result;
}
return ApiMessage.Status;
}
BOOL