From 8ca9e0b1abba7640e288df7b55b60903bc52fc9d Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 21 May 2020 17:06:22 +0200 Subject: [PATCH] kernelbase: Use the user shared data to implement GetTickCount(). Signed-off-by: Alexandre Julliard --- dlls/kernelbase/kernelbase.spec | 4 ++-- dlls/kernelbase/sync.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index de80e24551a..1f1a65fc853 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -725,8 +725,8 @@ # @ stub GetThreadSelectedCpuSets @ stdcall GetThreadTimes(long ptr ptr ptr ptr) @ stdcall GetThreadUILanguage() -@ stdcall GetTickCount() kernel32.GetTickCount -@ stdcall -ret64 GetTickCount64() kernel32.GetTickCount64 +@ stdcall GetTickCount() +@ stdcall -ret64 GetTickCount64() @ stdcall GetTimeFormatA(long long ptr str ptr long) kernel32.GetTimeFormatA @ stdcall GetTimeFormatEx(wstr long ptr wstr ptr long) kernel32.GetTimeFormatEx @ stdcall GetTimeFormatW(long long ptr wstr ptr long) kernel32.GetTimeFormatW diff --git a/dlls/kernelbase/sync.c b/dlls/kernelbase/sync.c index 6c2242e30d1..99706277da2 100644 --- a/dlls/kernelbase/sync.c +++ b/dlls/kernelbase/sync.c @@ -42,6 +42,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(sync); +static const struct _KUSER_SHARED_DATA *user_shared_data = (struct _KUSER_SHARED_DATA *)0x7ffe0000; + /* check if current version is NT or Win95 */ static inline BOOL is_version_nt(void) { @@ -126,6 +128,34 @@ static BOOL get_open_object_attributes( OBJECT_ATTRIBUTES *attr, UNICODE_STRING ***********************************************************************/ +/****************************************************************************** + * GetTickCount (kernelbase.@) + */ +ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void) +{ + /* note: we ignore TickCountMultiplier */ + return user_shared_data->u.TickCount.LowPart; +} + + +/****************************************************************************** + * GetTickCount64 (kernelbase.@) + */ +ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void) +{ + ULONG high, low; + + do + { + high = user_shared_data->u.TickCount.High1Time; + low = user_shared_data->u.TickCount.LowPart; + } + while (high != user_shared_data->u.TickCount.High2Time); + /* note: we ignore TickCountMultiplier */ + return (ULONGLONG)high << 32 | low; +} + + static HANDLE normalize_handle_if_console( HANDLE handle ) { static HANDLE wait_event;