util/clock.c: Add hook to prevent date/time changes

This commit is contained in:
Tau 2018-11-08 15:57:01 -05:00
parent acfa53fc5c
commit 851ea65609
3 changed files with 44 additions and 0 deletions

39
util/clock.c Normal file
View File

@ -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;
}

3
util/clock.h Normal file
View File

@ -0,0 +1,3 @@
#pragma once
void clock_hook_init(void);

View File

@ -7,6 +7,8 @@ util_lib = static_library(
capnhook.get_variable('hook_dep'), capnhook.get_variable('hook_dep'),
], ],
sources : [ sources : [
'clock.c',
'clock.h',
'crc.c', 'crc.c',
'crc.h', 'crc.h',
'dprintf.c', 'dprintf.c',