Author: mjmartin
Date: Thu Aug 19 10:52:36 2010
New Revision: 48568
URL:
http://svn.reactos.org/svn/reactos?rev=48568&view=rev
Log:
[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.
Modified:
trunk/reactos/subsystems/win32/win32k/ntuser/timer.c
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/timer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] Thu Aug 19 10:52:36
2010
@@ -30,7 +30,7 @@
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 @@
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 @@
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 @@
INT Type)
{
PTIMER pTmr;
- UINT Ret= IDEvent;
+ UINT Ret = IDEvent;
LARGE_INTEGER DueTime;
DueTime.QuadPart = (LONGLONG)(-5000000);
@@ -227,8 +229,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))
- IDEvent = 1;
+ Ret = 1;
pTmr = FindTimer(Window, IDEvent, Type);
@@ -243,11 +247,13 @@
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 @@
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 @@
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 @@
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 @@
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;