- 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
This commit is contained in:
Michael Martin 2010-08-19 10:52:36 +00:00
parent f87ad01e1a
commit 6a0074f795

View file

@ -30,7 +30,7 @@ static LONG TimeLast = 0;
static FAST_MUTEX Mutex; static FAST_MUTEX Mutex;
static RTL_BITMAP WindowLessTimersBitMap; static RTL_BITMAP WindowLessTimersBitMap;
static PVOID WindowLessTimersBitMapBuffer; static PVOID WindowLessTimersBitMapBuffer;
static ULONG HintIndex = 0; static ULONG HintIndex = 1;
ERESOURCE TimerLock; ERESOURCE TimerLock;
@ -97,9 +97,11 @@ RemoveTimer(PTIMER pTmr)
RemoveEntryList(&pTmr->ptmrList); RemoveEntryList(&pTmr->ptmrList);
if ((pTmr->pWnd == NULL) && (!(pTmr->flags & TMRF_SYSTEM))) 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(); IntLockWindowlessTimerBitmap();
RtlClearBit(&WindowLessTimersBitMap, pTmr->nID); RtlClearBit(&WindowLessTimersBitMap, IDEvent);
IntUnlockWindowlessTimerBitmap(); IntUnlockWindowlessTimerBitmap();
} }
UserDereferenceObject(pTmr); UserDereferenceObject(pTmr);
@ -155,7 +157,7 @@ FindSystemTimer(PMSG pMsg)
break; break;
pLE = pTmr->ptmrList.Flink; pLE = pTmr->ptmrList.Flink;
pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList); pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList);
} while (pTmr != FirstpTmr); } while (pTmr != FirstpTmr);
TimerLeave(); TimerLeave();
@ -200,7 +202,7 @@ IntSetTimer( PWINDOW_OBJECT Window,
INT Type) INT Type)
{ {
PTIMER pTmr; PTIMER pTmr;
UINT Ret= IDEvent; UINT Ret = IDEvent;
LARGE_INTEGER DueTime; LARGE_INTEGER DueTime;
DueTime.QuadPart = (LONGLONG)(-5000000); DueTime.QuadPart = (LONGLONG)(-5000000);
@ -227,8 +229,10 @@ IntSetTimer( PWINDOW_OBJECT Window,
Elapse = 10; 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)) if ((Window) && (IDEvent == 0))
IDEvent = 1; Ret = 1;
pTmr = FindTimer(Window, IDEvent, Type); pTmr = FindTimer(Window, IDEvent, Type);
@ -243,11 +247,13 @@ IntSetTimer( PWINDOW_OBJECT Window,
IntUnlockWindowlessTimerBitmap(); IntUnlockWindowlessTimerBitmap();
DPRINT1("Unable to find a free window-less timer id\n"); DPRINT1("Unable to find a free window-less timer id\n");
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
ASSERT(FALSE);
return 0; return 0;
} }
IDEvent = NUM_WINDOW_LESS_TIMERS - IDEvent;
Ret = IDEvent; Ret = IDEvent;
//HintIndex = IDEvent + 1;
IntUnlockWindowlessTimerBitmap(); IntUnlockWindowlessTimerBitmap();
} }
@ -271,7 +277,7 @@ IntSetTimer( PWINDOW_OBJECT Window,
pTmr->cmsRate = Elapse; pTmr->cmsRate = Elapse;
pTmr->pfn = TimerFunc; pTmr->pfn = TimerFunc;
pTmr->nID = IDEvent; pTmr->nID = IDEvent;
pTmr->flags = Type|TMRF_INIT; // Set timer to Init mode. pTmr->flags = Type|TMRF_INIT;
} }
else else
{ {
@ -319,6 +325,7 @@ SystemTimerSet( PWINDOW_OBJECT Window,
if (Window && Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess()) if (Window && Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess())
{ {
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
DPRINT("SysemTimerSet: Access Denied!\n");
return 0; return 0;
} }
return IntSetTimer( Window, nIDEvent, uElapse, lpTimerFunc, TMRF_SYSTEM); 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", DPRINT("IntKillTimer Window %x id %p systemtimer %s\n",
Window, IDEvent, SystemTimer ? "TRUE" : "FALSE"); Window, IDEvent, SystemTimer ? "TRUE" : "FALSE");
if ((Window) && (IDEvent == 0))
IDEvent = 1;
pTmr = FindTimer(Window, IDEvent, SystemTimer ? TMRF_SYSTEM : 0); pTmr = FindTimer(Window, IDEvent, SystemTimer ? TMRF_SYSTEM : 0);
if (pTmr) if (pTmr)
@ -532,7 +536,7 @@ InitTimerImpl(VOID)
ExInitializeFastMutex(&Mutex); ExInitializeFastMutex(&Mutex);
BitmapBytes = ROUND_UP(NUM_WINDOW_LESS_TIMERS, sizeof(ULONG) * 8) / 8; 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) if (WindowLessTimersBitMapBuffer == NULL)
{ {
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;