https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1e0bb664521bb7d2a3f7c…
commit 1e0bb664521bb7d2a3f7c25acfc30f4504880935
Author: James Tabor <james.tabor(a)reactos.org>
AuthorDate: Sat Apr 11 17:41:26 2020 -0500
Commit: James Tabor <james.tabor(a)reactos.org>
CommitDate: Sat Apr 11 17:41:26 2020 -0500
[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.
---
sdk/include/reactos/subsys/win/winmsg.h | 9 ++++++
win32ss/user/user32/include/user32.h | 1 +
win32ss/user/user32/misc/stubs.c | 53 ++++++++++++++++++++++++++++++---
3 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/sdk/include/reactos/subsys/win/winmsg.h
b/sdk/include/reactos/subsys/win/winmsg.h
index e445331eba3..df6aa389e1e 100644
--- a/sdk/include/reactos/subsys/win/winmsg.h
+++ b/sdk/include/reactos/subsys/win/winmsg.h
@@ -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;
diff --git a/win32ss/user/user32/include/user32.h b/win32ss/user/user32/include/user32.h
index 4993f4694a2..56415399ffc 100644
--- a/win32ss/user/user32/include/user32.h
+++ b/win32ss/user/user32/include/user32.h
@@ -51,6 +51,7 @@
/* CSRSS Header */
#include <csr/csr.h>
#include <win/winmsg.h>
+#include <psdk/dbt.h>
/* WINE Headers */
#include <wine/unicode.h>
diff --git a/win32ss/user/user32/misc/stubs.c b/win32ss/user/user32/misc/stubs.c
index a04ca5eddb9..8199c0222f7 100644
--- a/win32ss/user/user32/misc/stubs.c
+++ b/win32ss/user/user32/misc/stubs.c
@@ -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