|
Definition at line 37 of file instdev.c.
References _DEVICEEVENTMSG::dwFlags, _DEVICEEVENTMSG::dwResult, EXCEPTION_EXECUTE_HANDLER, _DEVICEEVENTMSG::hWnd, IsWindow(), _DEVICEEVENTMSG::lParam, NT_SUCCESS, NTSTATUS(), NtUserSetInformationThread(), NULL, PostMessage(), SendMessageTimeout(), Status, and _DEVICEEVENTMSG::wParam.
00040 {
00041 NTSTATUS Status = STATUS_SUCCESS;
00042 PDEVICEEVENTMSG a = ( PDEVICEEVENTMSG)&m->u.ApiMessageData;
00043 USERTHREAD_USEDESKTOPINFO utudi;
00044
00045 UNREFERENCED_PARAMETER(ReplyStatus);
00046
00047 try {
00048
00049
00050
00051
00052
00053
00054 utudi.hThread = NULL;
00055 utudi.drdRestore.pdeskRestore = NULL;
00056 Status = NtUserSetInformationThread(NtCurrentThread(),
00057 UserThreadUseActiveDesktop,
00058 &utudi, sizeof(utudi));
00059 if (! NT_SUCCESS(Status)) {
00060 #if DBG
00061 KdPrint(( "--> SrvDeviceEvent: NtUserSetInformationThread failed %d\n", Status));
00062 #endif
00063 goto Clean1;
00064 }
00065
00066
00067
00068
00069
00070
00071
00072 if ((a-> hWnd != HWND_BROADCAST) && ! IsWindow(a-> hWnd)) {
00073 Status = STATUS_INVALID_HANDLE;
00074 goto Clean0;
00075 }
00076
00077 if (a-> dwFlags) {
00078
00079
00080
00081
00082
00083
00084 RIPMSG3(RIP_VERBOSE, "--> SrvDeviceEvent: Sending WM_DEVICECHANGE to 0x%x, w 0x%x, l 0x%x",
00085 (ULONG_PTR)a-> hWnd,
00086 a-> wParam,
00087 a-> lParam);
00088
00089 if (! SendMessageTimeout(a-> hWnd, WM_DEVICECHANGE, a-> wParam, a-> lParam,
00090 SMTO_ABORTIFHUNG | SMTO_NORMAL,
00091 PNP_NOTIFY_TIMEOUT, &a-> dwResult)) {
00092 Status = STATUS_UNSUCCESSFUL;
00093 }
00094
00095 } else {
00096
00097
00098
00099
00100
00101
00102 RIPMSG3(RIP_VERBOSE, "--> SrvDeviceEvent: Posting WM_DEVICECHANGE to 0x%x, w 0x%x, l 0x%x",
00103 (ULONG_PTR)a-> hWnd,
00104 a-> wParam,
00105 a-> lParam);
00106
00107 if (! PostMessage(a-> hWnd, WM_DEVICECHANGE, a-> wParam, a-> lParam)) {
00108 Status = STATUS_UNSUCCESSFUL;
00109 }
00110 }
00111
00112 Clean0:
00113
00114
00115
00116
00117
00118
00119 NtUserSetInformationThread(NtCurrentThread(),
00120 UserThreadUseDesktop,
00121 &utudi, sizeof(utudi));
00122
00123 Clean1:
00124 ;
00125
00126 } except (EXCEPTION_EXECUTE_HANDLER) {
00127 KdPrint(( "SrvDeviceEvent generated an exception (%d)\n", GetExceptionCode()));
00128 Status = STATUS_UNSUCCESSFUL;
00129 }
00130
00131 return Status;
00132
00133 }
|