https://git.reactos.org/?p=reactos.git;a=commitdiff;h=94a42d43b59e59aa39952…
commit 94a42d43b59e59aa3995248577e74588af6727ea
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri Apr 12 07:56:04 2019 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Apr 12 07:56:04 2019 +0900
[WIN32SS][NTUSER] Fix message time (#1259)
Fix CORE-15565 and make #1245 GetMessageTime testcase successful. CORE-15565
- Erase MsqCalculateMessageTime function.
- Use (DWORD)EngGetTickCount() instead.
- Ghosting is temporarily disabled.
---
win32ss/gdi/eng/eng.h | 2 ++
win32ss/user/ntuser/event.c | 4 ++--
win32ss/user/ntuser/input.c | 8 ++------
win32ss/user/ntuser/keyboard.c | 8 ++------
win32ss/user/ntuser/main.c | 5 +----
win32ss/user/ntuser/message.c | 24 +++++++-----------------
win32ss/user/ntuser/misc.c | 6 ++----
win32ss/user/ntuser/mouse.c | 4 +---
win32ss/user/ntuser/msgqueue.c | 14 +++-----------
win32ss/user/ntuser/msgqueue.h | 6 ------
win32ss/user/ntuser/timer.c | 10 +++-------
11 files changed, 25 insertions(+), 66 deletions(-)
diff --git a/win32ss/gdi/eng/eng.h b/win32ss/gdi/eng/eng.h
index 2a467b15115..213e2733671 100644
--- a/win32ss/gdi/eng/eng.h
+++ b/win32ss/gdi/eng/eng.h
@@ -40,6 +40,8 @@ APIENTRY
EngGetTickCount(
VOID);
+#define EngGetTickCount32() (ULONG)EngGetTickCount()
+
HANDLE
APIENTRY
EngSecureMemForRead(
diff --git a/win32ss/user/ntuser/event.c b/win32ss/user/ntuser/event.c
index a82516cdcf0..f5a3a65c3bc 100644
--- a/win32ss/user/ntuser/event.c
+++ b/win32ss/user/ntuser/event.c
@@ -165,7 +165,7 @@ co_EVENT_CallEvents( DWORD event,
pEP->idObject,
pEP->idChild,
pEP->idThread,
- (DWORD)EngGetTickCount(),
+ EngGetTickCount32(),
pEH->Proc,
pEH->ihmod,
pEH->offPfn);
@@ -229,7 +229,7 @@ IntNotifyWinEvent(
idObject,
idChild,
PtrToUint(NtCurrentTeb()->ClientId.UniqueThread),
- (DWORD)EngGetTickCount(),
+ EngGetTickCount32(),
pEH->Proc,
pEH->ihmod,
pEH->offPfn);
diff --git a/win32ss/user/ntuser/input.c b/win32ss/user/ntuser/input.c
index 520ccca9ebb..2cc63634e7e 100644
--- a/win32ss/user/ntuser/input.c
+++ b/win32ss/user/ntuser/input.c
@@ -33,9 +33,7 @@ IntLastInputTick(BOOL bUpdate)
{
if (bUpdate)
{
- LARGE_INTEGER TickCount;
- KeQueryTickCount(&TickCount);
- LastInputTick = MsqCalculateMessageTime(&TickCount);
+ LastInputTick = EngGetTickCount32();
if (gpsi) gpsi->dwLastRITEventTickCount = LastInputTick;
}
return LastInputTick;
@@ -49,13 +47,11 @@ IntLastInputTick(BOOL bUpdate)
VOID FASTCALL
DoTheScreenSaver(VOID)
{
- LARGE_INTEGER TickCount;
DWORD Test, TO;
if (gspv.iScrSaverTimeout > 0) // Zero means Off.
{
- KeQueryTickCount(&TickCount);
- Test = MsqCalculateMessageTime(&TickCount);
+ Test = EngGetTickCount32();
Test = Test - LastInputTick;
TO = 1000 * gspv.iScrSaverTimeout;
if (Test > TO)
diff --git a/win32ss/user/ntuser/keyboard.c b/win32ss/user/ntuser/keyboard.c
index f72e275cf2d..33cf53e491c 100644
--- a/win32ss/user/ntuser/keyboard.c
+++ b/win32ss/user/ntuser/keyboard.c
@@ -976,7 +976,6 @@ UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
PKL pKl = NULL;
PKBDTABLES pKbdTbl;
PUSER_MESSAGE_QUEUE pFocusQueue;
- LARGE_INTEGER LargeTickCount;
DWORD dwTime;
BOOL bExt = (pKbdInput->dwFlags & KEYEVENTF_EXTENDEDKEY) ? TRUE : FALSE;
@@ -1030,8 +1029,7 @@ UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
dwTime = pKbdInput->time;
else
{
- KeQueryTickCount(&LargeTickCount);
- dwTime = MsqCalculateMessageTime(&LargeTickCount);
+ dwTime = EngGetTickCount32();
}
if (wVk == VK_RMENU && (pKbdTbl->fLocaleFlags & KLLF_ALTGR))
@@ -1143,7 +1141,6 @@ IntTranslateKbdMessage(LPMSG lpMsg,
WCHAR wch[3] = { 0 };
MSG NewMsg = { 0 };
PKBDTABLES pKbdTbl;
- LARGE_INTEGER LargeTickCount;
BOOL bResult = FALSE;
switch(lpMsg->message)
@@ -1176,8 +1173,7 @@ IntTranslateKbdMessage(LPMSG lpMsg,
/* Init pt, hwnd and time msg fields */
NewMsg.pt = gpsi->ptCursor;
NewMsg.hwnd = lpMsg->hwnd;
- KeQueryTickCount(&LargeTickCount);
- NewMsg.time = MsqCalculateMessageTime(&LargeTickCount);
+ NewMsg.time = EngGetTickCount32();
TRACE("Enter IntTranslateKbdMessage msg %s, vk %x\n",
lpMsg->message == WM_SYSKEYDOWN ? "WM_SYSKEYDOWN" :
"WM_KEYDOWN", lpMsg->wParam);
diff --git a/win32ss/user/ntuser/main.c b/win32ss/user/ntuser/main.c
index b790fd84ef5..9e63ce8f22e 100644
--- a/win32ss/user/ntuser/main.c
+++ b/win32ss/user/ntuser/main.c
@@ -443,7 +443,6 @@ InitThreadCallback(PETHREAD Thread)
int i;
NTSTATUS Status = STATUS_SUCCESS;
PTEB pTeb;
- LARGE_INTEGER LargeTickCount;
PRTL_USER_PROCESS_PARAMETERS ProcessParams;
Process = Thread->ThreadsProcess;
@@ -504,9 +503,7 @@ InitThreadCallback(PETHREAD Thread)
goto error;
}
- KeQueryTickCount(&LargeTickCount);
- ptiCurrent->timeLast = LargeTickCount.u.LowPart;
-
+ ptiCurrent->timeLast = EngGetTickCount32();
ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
if (ptiCurrent->MessageQueue == NULL)
{
diff --git a/win32ss/user/ntuser/message.c b/win32ss/user/ntuser/message.c
index 7564109c47d..2fd47c4fd8d 100644
--- a/win32ss/user/ntuser/message.c
+++ b/win32ss/user/ntuser/message.c
@@ -681,7 +681,6 @@ static LRESULT handle_internal_events( PTHREADINFO pti, PWND pWnd,
DWORD dwQEven
LRESULT FASTCALL
IntDispatchMessage(PMSG pMsg)
{
- LARGE_INTEGER TickCount;
LONG Time;
LRESULT retval = 0;
PTHREADINFO pti;
@@ -710,8 +709,7 @@ IntDispatchMessage(PMSG pMsg)
{
if (ValidateTimerCallback(pti,pMsg->lParam))
{
- KeQueryTickCount(&TickCount);
- Time = MsqCalculateMessageTime(&TickCount);
+ Time = EngGetTickCount32();
retval = co_IntCallWindowProc((WNDPROC)pMsg->lParam,
TRUE,
pMsg->hwnd,
@@ -727,8 +725,7 @@ IntDispatchMessage(PMSG pMsg)
PTIMER pTimer = FindSystemTimer(pMsg);
if (pTimer && pTimer->pfn)
{
- KeQueryTickCount(&TickCount);
- Time = MsqCalculateMessageTime(&TickCount);
+ Time = EngGetTickCount32();
pTimer->pfn(pMsg->hwnd, WM_SYSTIMER, (UINT)pMsg->wParam, Time);
}
return 0;
@@ -815,7 +812,6 @@ co_IntPeekMessage( PMSG Msg,
BOOL bGMSG )
{
PTHREADINFO pti;
- LARGE_INTEGER LargeTickCount;
BOOL RemoveMessages;
UINT ProcessMask;
BOOL Hit = FALSE;
@@ -833,9 +829,8 @@ co_IntPeekMessage( PMSG Msg,
do
{
- KeQueryTickCount(&LargeTickCount);
- pti->timeLast = LargeTickCount.u.LowPart;
- pti->pcti->tickLastMsgChecked = LargeTickCount.u.LowPart;
+ pti->timeLast = EngGetTickCount32();
+ pti->pcti->tickLastMsgChecked = pti->timeLast;
// Post mouse moves while looping through peek messages.
if (pti->MessageQueue->QF_flags & QF_MOUSEMOVED)
@@ -1152,7 +1147,6 @@ UserPostThreadMessage( PTHREADINFO pti,
LPARAM lParam )
{
MSG Message;
- LARGE_INTEGER LargeTickCount;
if (is_pointer_message(Msg))
{
@@ -1164,9 +1158,7 @@ UserPostThreadMessage( PTHREADINFO pti,
Message.wParam = wParam;
Message.lParam = lParam;
Message.pt = gpsi->ptCursor;
-
- KeQueryTickCount(&LargeTickCount);
- Message.time = MsqCalculateMessageTime(&LargeTickCount);
+ Message.time = EngGetTickCount32();
MsqPostMessage(pti, &Message, FALSE, QS_POSTMESSAGE, 0, 0);
return TRUE;
}
@@ -1193,7 +1185,6 @@ UserPostMessage( HWND Wnd,
{
PTHREADINFO pti;
MSG Message;
- LARGE_INTEGER LargeTickCount;
LONG_PTR ExtraInfo = 0;
Message.hwnd = Wnd;
@@ -1201,8 +1192,7 @@ UserPostMessage( HWND Wnd,
Message.wParam = wParam;
Message.lParam = lParam;
Message.pt = gpsi->ptCursor;
- KeQueryTickCount(&LargeTickCount);
- Message.time = MsqCalculateMessageTime(&LargeTickCount);
+ Message.time = EngGetTickCount32();
if (is_pointer_message(Message.message))
{
@@ -1468,7 +1458,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
if (Status == STATUS_TIMEOUT)
{
- if (MsqIsHung(ptiSendTo))
+ if (0 && MsqIsHung(ptiSendTo))
{
TRACE("Let's go Ghost!\n");
IntMakeHungWindowGhosted(hWnd);
diff --git a/win32ss/user/ntuser/misc.c b/win32ss/user/ntuser/misc.c
index 83d0ad1fe58..78408cac7a7 100644
--- a/win32ss/user/ntuser/misc.c
+++ b/win32ss/user/ntuser/misc.c
@@ -295,11 +295,9 @@ NtUserGetThreadState(
case THREADSTATE_UPTIMELASTREAD:
{
PTHREADINFO pti;
- LARGE_INTEGER LargeTickCount;
pti = PsGetCurrentThreadWin32Thread();
- KeQueryTickCount(&LargeTickCount);
- pti->timeLast = LargeTickCount.u.LowPart;
- pti->pcti->tickLastMsgChecked = LargeTickCount.u.LowPart;
+ pti->timeLast = EngGetTickCount32();
+ pti->pcti->tickLastMsgChecked = pti->timeLast;
}
break;
diff --git a/win32ss/user/ntuser/mouse.c b/win32ss/user/ntuser/mouse.c
index 46dfcfdd4ff..df8d7a6cc70 100644
--- a/win32ss/user/ntuser/mouse.c
+++ b/win32ss/user/ntuser/mouse.c
@@ -210,9 +210,7 @@ UserSendMouseInput(MOUSEINPUT *pmi, BOOL bInjected)
Msg.time = pmi->time;
if (!Msg.time)
{
- LARGE_INTEGER LargeTickCount;
- KeQueryTickCount(&LargeTickCount);
- Msg.time = MsqCalculateMessageTime(&LargeTickCount);
+ Msg.time = EngGetTickCount32();
}
/* Do GetMouseMovePointsEx FIFO. */
diff --git a/win32ss/user/ntuser/msgqueue.c b/win32ss/user/ntuser/msgqueue.c
index 446895915c4..2baa5a5ae49 100644
--- a/win32ss/user/ntuser/msgqueue.c
+++ b/win32ss/user/ntuser/msgqueue.c
@@ -551,13 +551,11 @@ VOID FASTCALL
IntCoalesceMouseMove(PTHREADINFO pti)
{
MSG Msg;
- LARGE_INTEGER LargeTickCount;
// Force time stamp to update, keeping message time in sync.
if (gdwMouseMoveTimeStamp == 0)
{
- KeQueryTickCount(&LargeTickCount);
- gdwMouseMoveTimeStamp = MsqCalculateMessageTime(&LargeTickCount);
+ gdwMouseMoveTimeStamp = EngGetTickCount32();
}
// Build mouse move message.
@@ -581,7 +579,6 @@ IntCoalesceMouseMove(PTHREADINFO pti)
VOID FASTCALL
co_MsqInsertMouseMessage(MSG* Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
{
- LARGE_INTEGER LargeTickCount;
MSLLHOOKSTRUCT MouseHookData;
// PDESKTOP pDesk;
PWND pwnd, pwndDesktop;
@@ -590,8 +587,7 @@ co_MsqInsertMouseMessage(MSG* Msg, DWORD flags, ULONG_PTR dwExtraInfo,
BOOL Hook
PUSER_MESSAGE_QUEUE MessageQueue;
PSYSTEM_CURSORINFO CurInfo;
- KeQueryTickCount(&LargeTickCount);
- Msg->time = MsqCalculateMessageTime(&LargeTickCount);
+ Msg->time = EngGetTickCount32();
MouseHookData.pt.x = LOWORD(Msg->lParam);
MouseHookData.pt.y = HIWORD(Msg->lParam);
@@ -2197,11 +2193,7 @@ co_MsqWaitForNewMessages(PTHREADINFO pti, PWND WndFilter,
BOOL FASTCALL
MsqIsHung(PTHREADINFO pti)
{
- LARGE_INTEGER LargeTickCount;
-
- KeQueryTickCount(&LargeTickCount);
-
- if ((LargeTickCount.u.LowPart - pti->timeLast) > MSQ_HUNG &&
+ if (EngGetTickCount32() - pti->timeLast > MSQ_HUNG &&
!(pti->pcti->fsWakeMask & QS_INPUT) &&
!PsGetThreadFreezeCount(pti->pEThread) &&
!(pti->ppi->W32PF_flags & W32PF_APPSTARTING))
diff --git a/win32ss/user/ntuser/msgqueue.h b/win32ss/user/ntuser/msgqueue.h
index 8b9d486675e..0927354165b 100644
--- a/win32ss/user/ntuser/msgqueue.h
+++ b/win32ss/user/ntuser/msgqueue.h
@@ -249,12 +249,6 @@ VOID APIENTRY MsqRemoveWindowMessagesFromQueue(PWND pWindow);
HANDLE FASTCALL IntMsqSetWakeMask(DWORD WakeMask);
BOOL FASTCALL IntMsqClearWakeMask(VOID);
-static __inline LONG
-MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount)
-{
- return (LONG)(TickCount->QuadPart * (KeQueryTimeIncrement() / 10000));
-}
-
VOID FASTCALL IdlePing(VOID);
VOID FASTCALL IdlePong(VOID);
BOOL FASTCALL co_MsqReplyMessage(LRESULT);
diff --git a/win32ss/user/ntuser/timer.c b/win32ss/user/ntuser/timer.c
index fc348eeba17..9a7789d9aec 100644
--- a/win32ss/user/ntuser/timer.c
+++ b/win32ss/user/ntuser/timer.c
@@ -399,7 +399,6 @@ PostTimerMessages(PWND Window)
PTHREADINFO pti;
BOOL Hit = FALSE;
PTIMER pTmr;
- LARGE_INTEGER TickCount;
pti = PsGetCurrentThreadWin32Thread();
@@ -412,13 +411,11 @@ PostTimerMessages(PWND Window)
(pTmr->pti == pti) &&
((pTmr->pWnd == Window) || (Window == NULL)) )
{
- KeQueryTickCount(&TickCount);
-
Msg.hwnd = (pTmr->pWnd) ? pTmr->pWnd->head.h : 0;
Msg.message = (pTmr->flags & TMRF_SYSTEM) ? WM_SYSTIMER : WM_TIMER;
Msg.wParam = (WPARAM) pTmr->nID;
Msg.lParam = (LPARAM) pTmr->pfn;
- Msg.time = MsqCalculateMessageTime(&TickCount);
+ Msg.time = EngGetTickCount32();
// Fix all wine win:test_GetMessagePos WM_TIMER tests. See CORE-10867.
Msg.pt = gpsi->ptCursor;
@@ -448,7 +445,7 @@ VOID
FASTCALL
ProcessTimers(VOID)
{
- LARGE_INTEGER TickCount, DueTime;
+ LARGE_INTEGER DueTime;
LONG Time;
PLIST_ENTRY pLE;
PTIMER pTmr;
@@ -456,8 +453,7 @@ ProcessTimers(VOID)
TimerEnterExclusive();
pLE = TimersListHead.Flink;
- KeQueryTickCount(&TickCount);
- Time = MsqCalculateMessageTime(&TickCount);
+ Time = EngGetTickCount32();
DueTime.QuadPart = (LONGLONG)(-97656); // 1024hz .9765625 ms set to 10.0 ms