sao: port clock changes from dniel segatools
This commit is contained in:
parent
42bdad96a6
commit
6a2682eaaf
@ -4,6 +4,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "hook/table.h"
|
#include "hook/table.h"
|
||||||
|
#include "hook/procaddr.h"
|
||||||
|
|
||||||
#include "platform/clock.h"
|
#include "platform/clock.h"
|
||||||
|
|
||||||
@ -16,17 +17,12 @@ static DWORD WINAPI my_GetTimeZoneInformation(TIME_ZONE_INFORMATION *tzinfo);
|
|||||||
static BOOL WINAPI my_SetLocalTime(SYSTEMTIME *in);
|
static BOOL WINAPI my_SetLocalTime(SYSTEMTIME *in);
|
||||||
static BOOL WINAPI my_SetSystemTime(SYSTEMTIME *in);
|
static BOOL WINAPI my_SetSystemTime(SYSTEMTIME *in);
|
||||||
static BOOL WINAPI my_SetTimeZoneInformation(TIME_ZONE_INFORMATION *tzinfo);
|
static BOOL WINAPI my_SetTimeZoneInformation(TIME_ZONE_INFORMATION *tzinfo);
|
||||||
static BOOL WINAPI my_AdjustTokenPrivileges(
|
|
||||||
HANDLE TokenHandle,
|
|
||||||
BOOL DisableAllPrivileges,
|
|
||||||
PTOKEN_PRIVILEGES NewState,
|
|
||||||
DWORD BufferLength,
|
|
||||||
PTOKEN_PRIVILEGES PreviousState,
|
|
||||||
PDWORD ReturnLength);
|
|
||||||
|
|
||||||
static BOOL (WINAPI * next_GetSystemTimeAsFileTime)(FILETIME *out);
|
static BOOL (WINAPI * next_GetSystemTimeAsFileTime)(FILETIME *out);
|
||||||
static int64_t clock_current_day;
|
static int64_t clock_current_day;
|
||||||
|
static bool clock_timezone;
|
||||||
static bool clock_time_warp;
|
static bool clock_time_warp;
|
||||||
|
static bool clock_writeable;
|
||||||
|
|
||||||
static const struct hook_symbol clock_base_hook_syms[] = {
|
static const struct hook_symbol clock_base_hook_syms[] = {
|
||||||
{
|
{
|
||||||
@ -36,13 +32,6 @@ static const struct hook_symbol clock_base_hook_syms[] = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct hook_symbol clock_perm_hook_syms[] = {
|
|
||||||
{
|
|
||||||
.name = "AdjustTokenPrivileges",
|
|
||||||
.patch = my_AdjustTokenPrivileges,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct hook_symbol clock_read_hook_syms[] = {
|
static const struct hook_symbol clock_read_hook_syms[] = {
|
||||||
{
|
{
|
||||||
.name = "GetLocalTime",
|
.name = "GetLocalTime",
|
||||||
@ -172,7 +161,7 @@ static BOOL WINAPI my_GetSystemTime(SYSTEMTIME *out)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if defined(LOG_CLOCK)
|
||||||
static int last_second;
|
static int last_second;
|
||||||
|
|
||||||
if (out->wSecond != last_second) {
|
if (out->wSecond != last_second) {
|
||||||
@ -235,60 +224,45 @@ static BOOL WINAPI my_SetTimeZoneInformation(TIME_ZONE_INFORMATION *in)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL WINAPI my_AdjustTokenPrivileges(
|
|
||||||
HANDLE TokenHandle,
|
|
||||||
BOOL DisableAllPrivileges,
|
|
||||||
PTOKEN_PRIVILEGES NewState,
|
|
||||||
DWORD BufferLength,
|
|
||||||
PTOKEN_PRIVILEGES PreviousState,
|
|
||||||
PDWORD ReturnLength)
|
|
||||||
{
|
|
||||||
dprintf("Clock: Blocked privilege update\n");
|
|
||||||
return false; // ....why???
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT clock_hook_init(const struct clock_config *cfg)
|
HRESULT clock_hook_init(const struct clock_config *cfg)
|
||||||
{
|
{
|
||||||
assert(cfg != NULL);
|
assert(cfg != NULL);
|
||||||
if (!cfg->enable) {
|
|
||||||
return S_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
clock_timezone = cfg->timezone;
|
||||||
clock_time_warp = cfg->timewarp;
|
clock_time_warp = cfg->timewarp;
|
||||||
|
clock_writeable = cfg->writeable;
|
||||||
|
|
||||||
if (cfg->timezone || cfg->timewarp || !cfg->writeable) {
|
clock_hook_insert_hooks(NULL);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clock_hook_insert_hooks(HMODULE target) {
|
||||||
|
if (clock_timezone || clock_time_warp || !clock_writeable) {
|
||||||
/* All the clock hooks require the core GSTAFT hook to be installed */
|
/* All the clock hooks require the core GSTAFT hook to be installed */
|
||||||
/* Note the ! up there btw. */
|
/* Note the ! up there btw. */
|
||||||
|
|
||||||
hook_table_apply(
|
hook_table_apply(
|
||||||
NULL,
|
target,
|
||||||
"kernel32.dll",
|
"kernel32.dll",
|
||||||
clock_base_hook_syms,
|
clock_base_hook_syms,
|
||||||
_countof(clock_base_hook_syms));
|
_countof(clock_base_hook_syms));
|
||||||
|
|
||||||
hook_table_apply(
|
|
||||||
NULL,
|
|
||||||
"ADVAPI32.dll",
|
|
||||||
clock_perm_hook_syms,
|
|
||||||
_countof(clock_perm_hook_syms));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg->timezone) {
|
if (clock_timezone) {
|
||||||
hook_table_apply(
|
hook_table_apply(
|
||||||
NULL,
|
target,
|
||||||
"kernel32.dll",
|
"kernel32.dll",
|
||||||
clock_read_hook_syms,
|
clock_read_hook_syms,
|
||||||
_countof(clock_read_hook_syms));
|
_countof(clock_read_hook_syms));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cfg->writeable) {
|
if (!clock_writeable) {
|
||||||
/* Install hook if this config parameter is FALSE! */
|
/* Install hook if this config parameter is FALSE! */
|
||||||
hook_table_apply(
|
hook_table_apply(
|
||||||
NULL,
|
target,
|
||||||
"kernel32.dll",
|
"kernel32.dll",
|
||||||
clock_write_hook_syms,
|
clock_write_hook_syms,
|
||||||
_countof(clock_write_hook_syms));
|
_countof(clock_write_hook_syms));
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
@ -12,3 +12,4 @@ struct clock_config {
|
|||||||
};
|
};
|
||||||
|
|
||||||
HRESULT clock_hook_init(const struct clock_config *cfg);
|
HRESULT clock_hook_init(const struct clock_config *cfg);
|
||||||
|
void clock_hook_insert_hooks(HMODULE target);
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "amcus/amcus.h"
|
#include "amcus/amcus.h"
|
||||||
#include "board/usio.h"
|
#include "board/usio.h"
|
||||||
#include "platform/epay.h"
|
#include "platform/epay.h"
|
||||||
|
#include "platform/clock.h"
|
||||||
|
|
||||||
#include "util/dprintf.h"
|
#include "util/dprintf.h"
|
||||||
|
|
||||||
@ -121,6 +122,7 @@ static HMODULE WINAPI my_LoadLibraryW(const wchar_t *name)
|
|||||||
path_hook_insert_hooks(result);
|
path_hook_insert_hooks(result);
|
||||||
amcus_insert_hooks(result);
|
amcus_insert_hooks(result);
|
||||||
reg_hook_apply_hooks(result);
|
reg_hook_apply_hooks(result);
|
||||||
|
clock_hook_insert_hooks(result);
|
||||||
usio_hook_proc_addr(result);
|
usio_hook_proc_addr(result);
|
||||||
proc_addr_insert_hooks(result);
|
proc_addr_insert_hooks(result);
|
||||||
}
|
}
|
||||||
@ -135,6 +137,7 @@ static HMODULE WINAPI my_LoadLibraryW(const wchar_t *name)
|
|||||||
serial_hook_apply_hooks(dep_mod);
|
serial_hook_apply_hooks(dep_mod);
|
||||||
reg_hook_apply_hooks(dep_mod);
|
reg_hook_apply_hooks(dep_mod);
|
||||||
epay_insert_hook(dep_mod);
|
epay_insert_hook(dep_mod);
|
||||||
|
clock_hook_insert_hooks(dep_mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user