Author: fireball Date: Thu Oct 28 13:39:49 2010 New Revision: 49328
URL: http://svn.reactos.org/svn/reactos?rev=49328&view=rev Log: - Add support for shell window hooks in win32k, based on trunk's code. It's not beautiful however it's well isolated and easy for future merges. - The proper code for keeping a list of registered windows for shell hook notifications in desktop structure is commented out for debugging purposes, and the list is global atm. - Thanks to Maarten Kroese, this work is partially based on his patch.
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/user.h branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/user.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/user.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/user.h [iso-8859-1] Thu Oct 28 13:39:49 2010 @@ -62,6 +62,7 @@ struct hook_table *global_hooks; /* table of global hooks on this desktop */ struct timeout_user *close_timeout; /* timeout before closing the desktop */ unsigned int users; /* processes and threads using this desktop */ + struct list shell_hooks; /* list of registered shell hooks */ };
struct region
Modified: branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] Thu Oct 28 13:39:49 2010 @@ -82,6 +82,9 @@ RosUserToUnicodeEx 7 RosUserMapVirtualKeyEx 4 RosUserGetAsyncKeyState 1 +RosUserRegisterShellHookWindow 1 +RosUserDeRegisterShellHookWindow 1 +RosUserBuildShellHookHwndList 0 SwmAddWindow 4 SwmAddDesktopWindow 3 SwmRemoveWindow 1
Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c [iso-8859-1] Thu Oct 28 13:39:49 2010 @@ -11,6 +11,7 @@ #include <win32k.h>
#include "object.h" +#include "user.h"
#define NDEBUG #include <debug.h> @@ -19,6 +20,16 @@ int debug_level = 0;
unsigned int global_error; + +typedef struct _SHELL_HOOK_WINDOW +{ + struct list ListEntry; + HWND hWnd; +} SHELL_HOOK_WINDOW, *PSHELL_HOOK_WINDOW; + +static struct list global_shell_hooks = LIST_INIT(global_shell_hooks); + +struct desktop *get_desktop_obj( PPROCESSINFO process, obj_handle_t handle, unsigned int access );
/* PRIVATE FUNCTIONS *********************************************************/
@@ -178,4 +189,141 @@ return ULargeInt.QuadPart / 10000000; }
+BOOL NTAPI +RosUserRegisterShellHookWindow(HWND hWnd) +{ + //PPROCESSINFO process = PsGetCurrentProcessWin32Process(); + //struct desktop *desktop; + struct list *entry, *shell_hooks; + PSHELL_HOOK_WINDOW hook_entry; + + DPRINT("UserRegisterShellHookWindow\n"); + + UserEnterExclusive(); + + //if (process->desktop && (desktop = get_desktop_obj( process, process->desktop, 0 ))) + { + shell_hooks = &global_shell_hooks; + + /* First deregister the window, so we can be sure it's never twice in the + * list. + */ + LIST_FOR_EACH(entry, shell_hooks) + { + hook_entry = LIST_ENTRY( entry, SHELL_HOOK_WINDOW, ListEntry ); + + if (hook_entry->hWnd == hWnd) + { + list_remove(&hook_entry->ListEntry); + ExFreePool(hook_entry); + //release_object( desktop ); + break; + } + } + + hook_entry = ExAllocatePool(PagedPool, sizeof(SHELL_HOOK_WINDOW)); + + if (!hook_entry) + { + //release_object( desktop ); + UserLeave(); + return FALSE; + } + + hook_entry->hWnd = hWnd; + list_add_tail(shell_hooks, &hook_entry->ListEntry); + + //release_object( desktop ); + } + + UserLeave(); + + return TRUE; +} + +BOOL NTAPI +RosUserDeRegisterShellHookWindow(HWND hWnd) +{ + //PPROCESSINFO process = PsGetCurrentProcessWin32Process(); + //struct desktop *desktop; + struct list *entry, *shell_hooks; + PSHELL_HOOK_WINDOW hook_entry; + + UserEnterExclusive(); + + //if (process->desktop && (desktop = get_desktop_obj( process, process->desktop, 0 ))) + { + shell_hooks = &global_shell_hooks; + + LIST_FOR_EACH(entry, shell_hooks) + { + hook_entry = LIST_ENTRY( entry, SHELL_HOOK_WINDOW, ListEntry ); + + if (hook_entry->hWnd == hWnd) + { + list_remove(&hook_entry->ListEntry); + ExFreePool(hook_entry); + //release_object( desktop ); + UserLeave(); + return TRUE; + } + } + + //release_object( desktop ); + } + + UserLeave(); + return FALSE; +} + +HWND * NTAPI +RosUserBuildShellHookHwndList() +{ + //PPROCESSINFO process = PsGetCurrentProcessWin32Process(); + //struct desktop *desktop; + struct list *entry, *shell_hooks; + PSHELL_HOOK_WINDOW hook_entry; + ULONG entries=0; + HWND* list = NULL; + + UserEnterExclusive(); + + //if (process->desktop && (desktop = get_desktop_obj( process, process->desktop, 0 ))) + { + shell_hooks = &global_shell_hooks; + + /* fixme: if we save nb elements in desktop, we dont have to loop to find nb entries */ + LIST_FOR_EACH(entry, shell_hooks) + entries++; + + if (!entries) + { + //release_object( desktop ); + UserLeave(); + return NULL; + } + + list = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(HWND) * (entries + 1)); /* alloc one extra for nullterm */ + if (list) + { + HWND* cursor = list; + + LIST_FOR_EACH(entry, shell_hooks) + { + hook_entry = LIST_ENTRY( entry, SHELL_HOOK_WINDOW, ListEntry ); + + *cursor++ = hook_entry->hWnd; + } + + *cursor = NULL; /* nullterm list */ + } + + //release_object( desktop ); + } + + UserLeave(); + + return list; +} + /* EOF */
Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c [iso-8859-1] Thu Oct 28 13:39:49 2010 @@ -222,6 +222,7 @@ desktop->close_timeout = NULL; desktop->users = 0; list_add_tail( &winstation->desktops, &desktop->entry ); + list_init( &desktop->shell_hooks ); } } ExFreePool( full_name );