Re: CallNextHookEx16 strageness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 23, 2002 at 12:01:25PM -0700, Alexandre Julliard wrote:
> Michael Stefaniuc <mstefani@redhat.com> writes:
> 
> > I don't know what the right fix would be, I'm seeing two possibilities:
> > - remove in CallNextHookEx16 the check
> > 	if (HIWORD(hhook) != HOOK_MAGIC) return 0; 
> > - or transform in DefHookProc16 and ShellHookProc16 the first parameter
> >   passed to CallNextHookEx16 to a real HHOOK with the HIWORD set to 'HC'
> 
> The second is right, we should always pass a real HHOOK. In fact a
> hook handle is 32 bit even in Win16, so it's never correct to assign
> it to a HANDLE16; we do this at a few other places too, that should
> probably be fixed.
I've changed DECLARE_OLD_HANDLE(HHOOK) to DECLARE_HANDLE(HOOK) and I'm
compiling wine with -DSTRICT and the two above functions were the only
ones that did an implicit conversion from a HANDLE16 to a HHOOK. There
is only one cast to HHANDLE but that should be ok:
return (HHOOK)( handle? MAKELONG( handle, HOOK_MAGIC ) : 0 );

It seems that we don't have an implicit transformation of a HHOOK to a
HANDLE16. Most of the internal HOOK_* functions are using HANDLE16's and
the few functions that accepts as parameter a HHOOK are checking for the
presence of the HOOK_MAGIC and are doing the conversion to a HANDLE16
with LOWORD(hhook). I've also looked over the casts to a HANDLE16 and it
seems that no HHOOK is transformed this way.

The attached patch fixes the bug and also converts HHOOK to a void*


License: LGPL, X11
Changelog:
    Michael Stefaniuc <mstefani@redhat.com>
    - fix the calls to CallNextHookEx16()
    - convert HHOOK to a void*

bye
	michael
-- 
Michael Stefaniuc               Tel.: +49-711-96437-199
System Administration           Fax.: +49-711-96437-111
Red Hat GmbH                    Email: mstefani@redhat.com
Hauptstaetterstr. 58            http://www.redhat.de/
D-70178 Stuttgart
Index: include/windef.h
===================================================================
RCS file: /home/wine/wine/include/windef.h,v
retrieving revision 1.65
diff -u -r1.65 windef.h
--- include/windef.h	19 Jul 2002 00:28:13 -0000	1.65
+++ include/windef.h	23 Jul 2002 21:40:35 -0000
@@ -79,7 +79,7 @@
 DECLARE_HANDLE(HDESK);
 DECLARE_OLD_HANDLE(HENHMETAFILE);
 DECLARE_OLD_HANDLE(HFONT);
-DECLARE_OLD_HANDLE(HHOOK);
+DECLARE_HANDLE(HHOOK);
 DECLARE_OLD_HANDLE(HICON);
 DECLARE_OLD_HANDLE(HINSTANCE);
 DECLARE_OLD_HANDLE(HKEY);
Index: windows/hook.c
===================================================================
RCS file: /home/wine/wine/windows/hook.c,v
retrieving revision 1.35
diff -u -r1.35 hook.c
--- windows/hook.c	10 Jul 2002 23:20:49 -0000	1.35
+++ windows/hook.c	23 Jul 2002 21:40:35 -0000
@@ -841,7 +841,7 @@
  /* remove all system hooks registered by this module */
 
   HOOKDATA*     hptr;
-  HHOOK         hook, next;
+  HANDLE16      hook, next;
   int           id;
 
   for( id = WH_MINHOOK; id <= WH_MAXHOOK; id++ )
@@ -870,7 +870,7 @@
   /* remove all hooks registered by the current queue */
 
   HOOKDATA*	hptr = NULL;
-  HHOOK 	hook, next;
+  HANDLE16 	hook, next;
   int 		id;
 
   for( id = WH_MINHOOK; id <= WH_MAXHOOK; id++ )
@@ -1057,7 +1057,8 @@
     MESSAGEQUEUE *queue;
 
     if (!(queue = QUEUE_Current())) return 0;
-    return CallNextHookEx16( queue->hCurHook, code, wParam, lParam );
+    return CallNextHookEx16( (HHOOK)MAKELONG(queue->hCurHook, HOOK_MAGIC),
+			    code, wParam, lParam );
 }
 
 
Index: dlls/shell32/shell.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell.c,v
retrieving revision 1.41
diff -u -r1.41 shell.c
--- dlls/shell32/shell.c	21 Jun 2002 20:08:50 -0000	1.41
+++ dlls/shell32/shell.c	23 Jul 2002 21:40:35 -0000
@@ -45,6 +45,8 @@
 WINE_DECLARE_DEBUG_CHANNEL(exec);
 
 
+#define HOOK_MAGIC  ((int)'H' | (int)'K' << 8)  /* 'HK' */
+
 typedef struct {     /* structure for dropped files */
  WORD     wSize;
  POINT16  ptMousePos;
@@ -494,7 +496,8 @@
         }
 	PostMessageA( SHELL_hWnd, uMsg, wParam, 0 );
     }
-    return CallNextHookEx16( WH_SHELL, code, wParam, lParam );
+    return CallNextHookEx16( (HHOOK)MAKELONG(WH_SHELL, HOOK_MAGIC), code,
+			    wParam, lParam );
 }
 
 /*************************************************************************

Attachment: pgp00016.pgp
Description: PGP signature


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux