mirror of
https://github.com/reactos/reactos.git
synced 2024-10-04 08:25:53 +00:00
Fix calling conventions and do not unload setupapi.dll after registering the notification. Thank you Thomas.
svn path=/trunk/; revision=29206
This commit is contained in:
parent
d42fa2d392
commit
9f930ed173
|
@ -9,14 +9,17 @@
|
|||
#define CR_INVALID_DATA 0x0000001F
|
||||
#endif
|
||||
|
||||
typedef DWORD (*CMP_REGNOTIFY) (HANDLE, LPVOID, DWORD, PULONG);
|
||||
typedef DWORD (*CMP_UNREGNOTIFY) (ULONG );
|
||||
typedef DWORD STDCALL (*CMP_REGNOTIFY) (HANDLE, LPVOID, DWORD, PULONG);
|
||||
typedef DWORD STDCALL (*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 */
|
||||
#define IsBadWritePtr(lp, n) ((DWORD)lp==n?0:0)
|
||||
|
||||
|
||||
static HINSTANCE hSetupApi = NULL;
|
||||
|
||||
BOOL STDCALL _InternalLoadString
|
||||
(
|
||||
HINSTANCE hInstance,
|
||||
|
@ -253,16 +256,16 @@ RegisterDeviceNotificationW(
|
|||
DWORD ConfigRet = 0;
|
||||
CMP_REGNOTIFY RegNotify = NULL;
|
||||
HDEVNOTIFY hDevNotify = NULL;
|
||||
HINSTANCE hSetupApi = LoadLibraryA("SETUPAPI.DLL");
|
||||
if ( hSetupApi == NULL ) hSetupApi = LoadLibraryA("SETUPAPI.DLL");
|
||||
if ( hSetupApi == NULL ) return NULL;
|
||||
RegNotify = (CMP_REGNOTIFY) GetProcAddress ( hSetupApi, "CMP_RegisterNotification");
|
||||
if (RegNotify == NULL)
|
||||
{
|
||||
FreeLibrary ( hSetupApi );
|
||||
hSetupApi = NULL;
|
||||
return NULL;
|
||||
}
|
||||
ConfigRet = RegNotify ( hRecipient, NotificationFilter, Flags, (PULONG) &hDevNotify);
|
||||
FreeLibrary ( hSetupApi );
|
||||
if (ConfigRet != CR_SUCCESS)
|
||||
{
|
||||
switch (ConfigRet)
|
||||
|
@ -295,16 +298,16 @@ UnregisterDeviceNotification(
|
|||
{
|
||||
DWORD ConfigRet = 0;
|
||||
CMP_UNREGNOTIFY UnRegNotify = NULL;
|
||||
HINSTANCE hSetupApi = LoadLibraryA("SETUPAPI.DLL");
|
||||
if ( hSetupApi == NULL ) hSetupApi = LoadLibraryA("SETUPAPI.DLL");
|
||||
if ( hSetupApi == NULL ) return FALSE;
|
||||
UnRegNotify = (CMP_UNREGNOTIFY) GetProcAddress ( hSetupApi, "CMP_UnregisterNotification");
|
||||
if (UnRegNotify == NULL)
|
||||
{
|
||||
FreeLibrary ( hSetupApi );
|
||||
hSetupApi = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
ConfigRet = UnRegNotify ( (ULONG) Handle );
|
||||
FreeLibrary ( hSetupApi );
|
||||
if (ConfigRet != CR_SUCCESS)
|
||||
{
|
||||
switch (ConfigRet)
|
||||
|
|
Loading…
Reference in a new issue