From: Michael Martin Date: Thu, 19 Aug 2010 10:52:36 +0000 (+0000) Subject: [Win32k] X-Git-Tag: ReactOS-0.3.12~161 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=6a0074f795711327b29b82e153a564a4eba4833f [Win32k] - For SetTimer nIDEvent can be 0 in which case return 1. Zero still needs to be used for nIDEvent when killing the timer. Fixes bug 5553. - Modify windowless timers to use IDEvent values decrementing from the max number of windowless timers vice incrementing from 1. Done to match windows behavior. svn path=/trunk/; revision=48568 --- diff --git a/reactos/subsystems/win32/win32k/ntuser/timer.c b/reactos/subsystems/win32/win32k/ntuser/timer.c index 984b206a6b8..2f4e2189f3f 100644 --- a/reactos/subsystems/win32/win32k/ntuser/timer.c +++ b/reactos/subsystems/win32/win32k/ntuser/timer.c @@ -30,7 +30,7 @@ static LONG TimeLast = 0; static FAST_MUTEX Mutex; static RTL_BITMAP WindowLessTimersBitMap; static PVOID WindowLessTimersBitMapBuffer; -static ULONG HintIndex = 0; +static ULONG HintIndex = 1; ERESOURCE TimerLock; @@ -97,9 +97,11 @@ RemoveTimer(PTIMER pTmr) RemoveEntryList(&pTmr->ptmrList); if ((pTmr->pWnd == NULL) && (!(pTmr->flags & TMRF_SYSTEM))) { - DPRINT("Clearing Bit %d)\n", pTmr->nID); + UINT_PTR IDEvent; + + IDEvent = NUM_WINDOW_LESS_TIMERS - pTmr->nID; IntLockWindowlessTimerBitmap(); - RtlClearBit(&WindowLessTimersBitMap, pTmr->nID); + RtlClearBit(&WindowLessTimersBitMap, IDEvent); IntUnlockWindowlessTimerBitmap(); } UserDereferenceObject(pTmr); @@ -155,7 +157,7 @@ FindSystemTimer(PMSG pMsg) break; pLE = pTmr->ptmrList.Flink; - pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList); + pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList); } while (pTmr != FirstpTmr); TimerLeave(); @@ -200,7 +202,7 @@ IntSetTimer( PWINDOW_OBJECT Window, INT Type) { PTIMER pTmr; - UINT Ret= IDEvent; + UINT Ret = IDEvent; LARGE_INTEGER DueTime; DueTime.QuadPart = (LONGLONG)(-5000000); @@ -227,8 +229,10 @@ IntSetTimer( PWINDOW_OBJECT Window, Elapse = 10; } + /* Passing an IDEvent of 0 and the SetTimer returns 1. + It will create the timer with an ID of 0 */ if ((Window) && (IDEvent == 0)) - IDEvent = 1; + Ret = 1; pTmr = FindTimer(Window, IDEvent, Type); @@ -243,11 +247,13 @@ IntSetTimer( PWINDOW_OBJECT Window, IntUnlockWindowlessTimerBitmap(); DPRINT1("Unable to find a free window-less timer id\n"); SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + ASSERT(FALSE); return 0; } + IDEvent = NUM_WINDOW_LESS_TIMERS - IDEvent; Ret = IDEvent; - //HintIndex = IDEvent + 1; + IntUnlockWindowlessTimerBitmap(); } @@ -271,7 +277,7 @@ IntSetTimer( PWINDOW_OBJECT Window, pTmr->cmsRate = Elapse; pTmr->pfn = TimerFunc; pTmr->nID = IDEvent; - pTmr->flags = Type|TMRF_INIT; // Set timer to Init mode. + pTmr->flags = Type|TMRF_INIT; } else { @@ -319,6 +325,7 @@ SystemTimerSet( PWINDOW_OBJECT Window, if (Window && Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess()) { SetLastWin32Error(ERROR_ACCESS_DENIED); + DPRINT("SysemTimerSet: Access Denied!\n"); return 0; } return IntSetTimer( Window, nIDEvent, uElapse, lpTimerFunc, TMRF_SYSTEM); @@ -509,9 +516,6 @@ IntKillTimer(PWINDOW_OBJECT Window, UINT_PTR IDEvent, BOOL SystemTimer) DPRINT("IntKillTimer Window %x id %p systemtimer %s\n", Window, IDEvent, SystemTimer ? "TRUE" : "FALSE"); - if ((Window) && (IDEvent == 0)) - IDEvent = 1; - pTmr = FindTimer(Window, IDEvent, SystemTimer ? TMRF_SYSTEM : 0); if (pTmr) @@ -532,7 +536,7 @@ InitTimerImpl(VOID) ExInitializeFastMutex(&Mutex); BitmapBytes = ROUND_UP(NUM_WINDOW_LESS_TIMERS, sizeof(ULONG) * 8) / 8; - WindowLessTimersBitMapBuffer = ExAllocatePoolWithTag(PagedPool, BitmapBytes, TAG_TIMERBMP); + WindowLessTimersBitMapBuffer = ExAllocatePoolWithTag(NonPagedPool, BitmapBytes, TAG_TIMERBMP); if (WindowLessTimersBitMapBuffer == NULL) { return STATUS_UNSUCCESSFUL;