From 5baf5558ffc6b50dea5aae53e92e0dc1d65aa9d4 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 25 Sep 2007 22:28:35 +0000 Subject: [PATCH] Implement RegisterDeviceNotificationAW and UnregisterDeviceNotification, based on Gdi32 OpenGL. svn path=/trunk/; revision=29204 --- reactos/dll/win32/user32/misc/resources.c | 99 +++++++++++++++++++++++ reactos/dll/win32/user32/misc/stubs.c | 43 ---------- reactos/dll/win32/user32/user32.def | 2 +- 3 files changed, 100 insertions(+), 44 deletions(-) diff --git a/reactos/dll/win32/user32/misc/resources.c b/reactos/dll/win32/user32/misc/resources.c index 700682f4468..6af1a05cbf3 100644 --- a/reactos/dll/win32/user32/misc/resources.c +++ b/reactos/dll/win32/user32/misc/resources.c @@ -2,6 +2,17 @@ #include +#ifndef _CFGMGR32_H_ +#define CR_SUCCESS 0x00000000 +#define CR_OUT_OF_MEMORY 0x00000002 +#define CR_INVALID_POINTER 0x00000003 +#define CR_FAILURE 0x00000013 +#define CR_INVALID_DATA 0x0000001F +#endif + +typedef DWORD (*CMP_REGNOTIFY) (HANDLE, LPVOID, DWORD, PULONG); +typedef DWORD (*CMP_UNREGNOTIFY) (ULONG ); + /* FIXME: Currently IsBadWritePtr is implemented using VirtualQuery which does not seem to work properly for stack address space. */ /* kill `left-hand operand of comma expression has no effect' warning */ @@ -228,4 +239,92 @@ int STDCALL LoadStringW return nStringLen; } + +/* + * @implemented + */ +HDEVNOTIFY +STDCALL +RegisterDeviceNotificationW( + HANDLE hRecipient, + LPVOID NotificationFilter, + DWORD Flags + ) +{ + DWORD ConfigRet = 0; + CMP_REGNOTIFY RegNotify = NULL; + HDEVNOTIFY hDevNotify = NULL; + HINSTANCE hSetupApi = LoadLibraryA("SETUPAPI.DLL"); + if (hSetupApi == NULL) return NULL; + RegNotify = (CMP_REGNOTIFY) GetProcAddress ( hSetupApi, "CMP_RegisterNotification"); + if (RegNotify == NULL) + { + FreeLibrary ( hSetupApi ); + return NULL; + } + ConfigRet = RegNotify ( hRecipient, NotificationFilter, Flags, (PULONG) &hDevNotify); + FreeLibrary ( hSetupApi ); + if (ConfigRet != CR_SUCCESS) + { + switch (ConfigRet) + { + case CR_OUT_OF_MEMORY: + SetLastError (ERROR_NOT_ENOUGH_MEMORY); + break; + case CR_INVALID_POINTER: + SetLastError (ERROR_INVALID_PARAMETER); + break; + case CR_INVALID_DATA: + SetLastError (ERROR_INVALID_DATA); + break; + case CR_FAILURE: + default: + SetLastError (ERROR_SERVICE_SPECIFIC_ERROR); + break; + } + } + return hDevNotify; +} + + +/* + * @implemented + */ +BOOL +STDCALL +UnregisterDeviceNotification( + HDEVNOTIFY Handle) +{ + DWORD ConfigRet = 0; + CMP_UNREGNOTIFY UnRegNotify = NULL; + HINSTANCE hSetupApi = LoadLibraryA("SETUPAPI.DLL"); + if (hSetupApi == NULL) return FALSE; + UnRegNotify = (CMP_UNREGNOTIFY) GetProcAddress ( hSetupApi, "CMP_UnregisterNotification"); + if (UnRegNotify == NULL) + { + FreeLibrary ( hSetupApi ); + return FALSE; + } + ConfigRet = UnRegNotify ( (ULONG) Handle ); + FreeLibrary ( hSetupApi ); + if (ConfigRet != CR_SUCCESS) + { + switch (ConfigRet) + { + case CR_INVALID_POINTER: + SetLastError (ERROR_INVALID_PARAMETER); + break; + case CR_INVALID_DATA: + SetLastError (ERROR_INVALID_DATA); + break; + case CR_FAILURE: + default: + SetLastError (ERROR_SERVICE_SPECIFIC_ERROR); + break; + } + return FALSE; + } + return TRUE; +} + /* EOF */ diff --git a/reactos/dll/win32/user32/misc/stubs.c b/reactos/dll/win32/user32/misc/stubs.c index ecad70006c5..1861055780e 100644 --- a/reactos/dll/win32/user32/misc/stubs.c +++ b/reactos/dll/win32/user32/misc/stubs.c @@ -105,19 +105,6 @@ LockWorkStation(VOID) } -/* - * @unimplemented - */ -BOOL -STDCALL -UnregisterDeviceNotification( - HDEVNOTIFY Handle) -{ - UNIMPLEMENTED; - return FALSE; -} - - /* * @unimplemented */ @@ -330,21 +317,6 @@ ClientThreadSetup ( VOID ) return FALSE; } -/* - * @unimplemented - */ -HDEVNOTIFY -STDCALL -RegisterDeviceNotificationW( - HANDLE hRecipient, - LPVOID NotificationFilter, - DWORD Flags - ) -{ - UNIMPLEMENTED; - return FALSE; -} - /* * @unimplemented */ @@ -394,21 +366,6 @@ CsrBroadcastSystemMessageExW( return FALSE; } -/* - * @unimplemented - */ -HDEVNOTIFY -STDCALL -RegisterDeviceNotificationA( - HANDLE hRecipient, - LPVOID NotificationFilter, - DWORD Flags - ) -{ - UNIMPLEMENTED; - return FALSE; -} - /* * @unimplemented */ diff --git a/reactos/dll/win32/user32/user32.def b/reactos/dll/win32/user32/user32.def index cf92d12d16c..911d9e395e3 100644 --- a/reactos/dll/win32/user32/user32.def +++ b/reactos/dll/win32/user32/user32.def @@ -549,7 +549,7 @@ RegisterClassExW@4 RegisterClassW@4 RegisterClipboardFormatA@4 RegisterClipboardFormatW@4 -RegisterDeviceNotificationA@12 +RegisterDeviceNotificationA@12=RegisterDeviceNotificationW@12 RegisterDeviceNotificationW@12 RegisterHotKey@16 RegisterLogonProcess@8