From 851ea656097ccfa2e114f1848b680bb294389891 Mon Sep 17 00:00:00 2001 From: Tau Date: Thu, 8 Nov 2018 15:57:01 -0500 Subject: [PATCH] util/clock.c: Add hook to prevent date/time changes --- util/clock.c | 39 +++++++++++++++++++++++++++++++++++++++ util/clock.h | 3 +++ util/meson.build | 2 ++ 3 files changed, 44 insertions(+) create mode 100644 util/clock.c create mode 100644 util/clock.h diff --git a/util/clock.c b/util/clock.c new file mode 100644 index 0000000..60e623a --- /dev/null +++ b/util/clock.c @@ -0,0 +1,39 @@ +#include "hook/table.h" + +#include "util/dprintf.h" + +static BOOL WINAPI my_SetSystemTime(void *whatever); +static BOOL WINAPI my_SetTimeZoneInformation(void *whatever); + +static const struct hook_symbol clock_hook_syms[] = { + { + .name = "SetSystemTime", + .patch = my_SetSystemTime, + }, { + .name = "SetTimeZoneInformation", + .patch = my_SetTimeZoneInformation, + } +}; + +void clock_hook_init(void) +{ + hook_table_apply( + NULL, + "kernel32.dll", + clock_hook_syms, + _countof(clock_hook_syms)); +} + +static BOOL WINAPI my_SetSystemTime(void *whatever) +{ + dprintf("Prevented application from screwing with the system clock\n"); + + return TRUE; +} + +static BOOL WINAPI my_SetTimeZoneInformation(void *whatever) +{ + dprintf("Prevented application from screwing with the timezone\n"); + + return TRUE; +} diff --git a/util/clock.h b/util/clock.h new file mode 100644 index 0000000..f3d242e --- /dev/null +++ b/util/clock.h @@ -0,0 +1,3 @@ +#pragma once + +void clock_hook_init(void); diff --git a/util/meson.build b/util/meson.build index 0fa3470..7a8d6fa 100644 --- a/util/meson.build +++ b/util/meson.build @@ -7,6 +7,8 @@ util_lib = static_library( capnhook.get_variable('hook_dep'), ], sources : [ + 'clock.c', + 'clock.h', 'crc.c', 'crc.h', 'dprintf.c',