Author: jimtabor Date: Tue Aug 5 21:05:17 2008 New Revision: 35138
URL: http://svn.reactos.org/svn/reactos?rev=35138&view=rev Log: Win32k Timers: - This is relative to bugs 3634 and 2393. Please leave additional information in bug report 2393. - Timer code should not be associated with message queues, since theses types of queues are subject to being destroyed. This creates a problem of loosing timers. - This is a first part of a rewrite of the timers. Moving the timers from the message queue to a linked list very similar to our DCE code. This will simplify timer handling too.
Modified: trunk/reactos/subsystems/win32/win32k/include/timer.h trunk/reactos/subsystems/win32/win32k/ntuser/hook.c trunk/reactos/subsystems/win32/win32k/ntuser/timer.c
Modified: trunk/reactos/subsystems/win32/win32k/include/timer.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/timer.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/timer.h [iso-8859-1] Tue Aug 5 21:05:17 2008 @@ -1,5 +1,17 @@ #ifndef _WIN32K_TIMER_H #define _WIN32K_TIMER_H + +typedef struct _TIMER +{ + LIST_ENTRY ptmrList; + PW32THREADINFO pti; + PWINDOW_OBJECT pWnd; // hWnd + UINT_PTR nID; // Specifies a nonzero timer identifier. + INT cmsCountdown; // uElapse + INT cmsRate; // uElapse + FLONG flags; + TIMERPROC pfn; // lpTimerFunc +} TIMER, *PTIMER;
NTSTATUS FASTCALL InitTimerImpl(VOID); BOOL FASTCALL IntKillTimer(HWND Wnd, UINT_PTR IDEvent, BOOL SystemTimer);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/hook.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/hook.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/hook.c [iso-8859-1] Tue Aug 5 21:05:17 2008 @@ -1131,7 +1131,7 @@ ModuleName.MaximumLength); if (! NT_SUCCESS(Status)) { - ExFreePool(Hook->ModuleName.Buffer); + ExFreePool(Hook->ModuleName.Buffer); UserDereferenceObject(Hook); IntRemoveHook(Hook, WinStaObj, FALSE); if (NULL != Thread)
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/timer.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] Tue Aug 5 21:05:17 2008 @@ -16,12 +16,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * PURPOSE: Window timers messages - * FILE: subsys/win32k/ntuser/timer.c + * FILE: subsystems/win32/win32k/ntuser/timer.c * PROGRAMER: Gunnar * Thomas Weidenmueller (w3seek@users.sourceforge.net) * REVISION HISTORY: 10/04/2003 Implemented System Timers @@ -36,6 +35,8 @@ #include <debug.h>
/* GLOBALS *******************************************************************/ + +static PTIMER FirstpTmr = NULL;
/* Windows 2000 has room for 32768 window-less timers */ #define NUM_WINDOW_LESS_TIMERS 1024 @@ -148,20 +149,40 @@ BOOL FASTCALL IntKillTimer(HWND Wnd, UINT_PTR IDEvent, BOOL SystemTimer) { + PWINDOW_OBJECT Window = NULL; + DPRINT("IntKillTimer wnd %x id %p systemtimer %s\n", Wnd, IDEvent, SystemTimer ? "TRUE" : "FALSE");
- if (! MsqKillTimer(PsGetCurrentThreadWin32Thread()->MessageQueue, Wnd, - IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER)) - { - DPRINT1("Unable to locate timer in message queue\n"); - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + if (Wnd) + { + Window = UserGetWindowObject(Wnd); + + if (! MsqKillTimer(PsGetCurrentThreadWin32Thread()->MessageQueue, Wnd, + IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER)) + { + // Give it another chance to find the timer. + if (Window && !( MsqKillTimer(Window->MessageQueue, Wnd, + IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER))) + { + DPRINT1("Unable to locate timer in message queue for Window.\n"); + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return FALSE; + } + } }
/* window-less timer? */ if ((Wnd == NULL) && ! SystemTimer) { + if (! MsqKillTimer(PsGetCurrentThreadWin32Thread()->MessageQueue, Wnd, + IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER)) + { + DPRINT1("Unable to locate timer in message queue for Window-less timer.\n"); + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return FALSE; + } + /* Release the id */ IntLockWindowlessTimerBitmap();
@@ -194,6 +215,12 @@
/* yes we need this, since ExAllocatePool isn't supposed to zero out allocated memory */ RtlClearAllBits(&WindowLessTimersBitMap); + + if (!FirstpTmr) + { + FirstpTmr = ExAllocatePoolWithTag(PagedPool, sizeof(TIMER), TAG_TIMERBMP); + if (FirstpTmr) InitializeListHead(&FirstpTmr->ptmrList); + }
return STATUS_SUCCESS; }