From 51994d59ff033644e8d4b6726fd89763027cc2d6 Mon Sep 17 00:00:00 2001 From: Tau Date: Fri, 23 Nov 2018 14:23:16 -0500 Subject: [PATCH] Combine both clock hooks Turns out the clock skew doesn't really work unless RTC and TZ changes are blocked as well. --- chunihook/dllmain.c | 3 +-- minihook/dllmain.c | 2 +- util/clock.c | 31 ++++++------------------------- util/clock.h | 3 +-- 4 files changed, 9 insertions(+), 30 deletions(-) diff --git a/chunihook/dllmain.c b/chunihook/dllmain.c index b75ce351..c6781fde 100644 --- a/chunihook/dllmain.c +++ b/chunihook/dllmain.c @@ -43,8 +43,7 @@ static DWORD CALLBACK chuni_pre_startup(void) /* Hook Win32 APIs */ - clock_set_hook_init(); - clock_skew_hook_init(); + clock_hook_init(); gfx_hook_init(); serial_hook_init(); diff --git a/minihook/dllmain.c b/minihook/dllmain.c index 2a3ba7ac..76de5495 100644 --- a/minihook/dllmain.c +++ b/minihook/dllmain.c @@ -17,7 +17,7 @@ static DWORD CALLBACK app_pre_startup(void) ds_hook_init(); nusec_hook_init(); - clock_skew_hook_init(); + clock_hook_init(); spike_hook_init("minispike.txt"); dprintf("--- End %s ---\n", __func__); diff --git a/util/clock.c b/util/clock.c index e22f14fd..5e51b704 100644 --- a/util/clock.c +++ b/util/clock.c @@ -16,18 +16,12 @@ static BOOL WINAPI my_SetTimeZoneInformation(TIME_ZONE_INFORMATION *tzinfo); static BOOL (WINAPI * next_GetSystemTimeAsFileTime)(FILETIME *out); static int64_t clock_current_day; -static const struct hook_symbol clock_skew_hook_syms[] = { - /* Canonical time */ - +static const struct hook_symbol clock_hook_syms[] = { { .name = "GetSystemTimeAsFileTime", .patch = my_GetSystemTimeAsFileTime, .link = (void **) &next_GetSystemTimeAsFileTime, - }, - - /* Derived time */ - - { + }, { .name = "GetLocalTime", .patch = my_GetLocalTime, }, { @@ -36,11 +30,7 @@ static const struct hook_symbol clock_skew_hook_syms[] = { }, { .name = "GetTimeZoneInformation", .patch = my_GetTimeZoneInformation, - }, -}; - -static const struct hook_symbol clock_set_hook_syms[] = { - { + }, { .name = "SetSystemTime", .patch = my_SetSystemTime, }, { @@ -182,20 +172,11 @@ static BOOL WINAPI my_SetTimeZoneInformation(TIME_ZONE_INFORMATION *in) return TRUE; } -void clock_set_hook_init(void) +void clock_hook_init(void) { hook_table_apply( NULL, "kernel32.dll", - clock_set_hook_syms, - _countof(clock_set_hook_syms)); -} - -void clock_skew_hook_init(void) -{ - hook_table_apply( - NULL, - "kernel32.dll", - clock_skew_hook_syms, - _countof(clock_skew_hook_syms)); + clock_hook_syms, + _countof(clock_hook_syms)); } diff --git a/util/clock.h b/util/clock.h index 30e53e8f..f3d242e0 100644 --- a/util/clock.h +++ b/util/clock.h @@ -1,4 +1,3 @@ #pragma once -void clock_set_hook_init(void); -void clock_skew_hook_init(void); +void clock_hook_init(void);