1
0
mirror of https://gitea.tendokyu.moe/Hay1tsme/segatools.git synced 2024-11-27 18:40:48 +01:00

port clock fixes from dniel segatools

This commit is contained in:
Hay1tsme 2024-08-20 10:14:10 -04:00
parent 5becf8798c
commit b7a961ff71
5 changed files with 25 additions and 9 deletions

View File

@ -10,6 +10,7 @@
#include "hooklib/reg.h"
#include "hook/procaddr.h"
#include "hooklib/serial.h"
#include "platform/clock.h"
#include "util/dprintf.h"
@ -96,6 +97,7 @@ static HMODULE WINAPI my_LoadLibraryW(const wchar_t *name)
path_hook_insert_hooks(result);
reg_hook_insert_hooks(result);
proc_addr_insert_hooks(result);
clock_hook_insert_hooks(result);
serial_hook_apply_hooks(result);
iohook_apply_hooks(result);
}

View File

@ -10,6 +10,7 @@
#include "hooklib/reg.h"
#include "hook/procaddr.h"
#include "hooklib/serial.h"
#include "platform/clock.h"
#include "util/dprintf.h"
@ -107,6 +108,7 @@ static HMODULE WINAPI my_LoadLibraryW(const wchar_t *name)
path_hook_insert_hooks(result);
reg_hook_insert_hooks(result);
proc_addr_insert_hooks(result);
clock_hook_insert_hooks(result);
serial_hook_apply_hooks(result);
iohook_apply_hooks(result);
}

View File

@ -6,6 +6,7 @@
#include "hooklib/dll.h"
#include "hooklib/path.h"
#include "platform/clock.h"
#include "util/dprintf.h"
@ -88,6 +89,7 @@ static HMODULE WINAPI my_LoadLibraryW(const wchar_t *name)
dll_hook_insert_hooks(result);
path_hook_insert_hooks(result);
clock_hook_insert_hooks(result);
}
}

View File

@ -4,6 +4,7 @@
#include <stdint.h>
#include "hook/table.h"
#include "hook/procaddr.h"
#include "platform/clock.h"
@ -19,7 +20,9 @@ static BOOL WINAPI my_SetTimeZoneInformation(TIME_ZONE_INFORMATION *tzinfo);
static BOOL (WINAPI * next_GetSystemTimeAsFileTime)(FILETIME *out);
static int64_t clock_current_day;
static bool clock_timezone;
static bool clock_time_warp;
static bool clock_writeable;
static const struct hook_symbol clock_base_hook_syms[] = {
{
@ -158,7 +161,7 @@ static BOOL WINAPI my_GetSystemTime(SYSTEMTIME *out)
return ok;
}
#if 0
#if defined(LOG_CLOCK)
static int last_second;
if (out->wSecond != last_second) {
@ -225,35 +228,41 @@ HRESULT clock_hook_init(const struct clock_config *cfg)
{
assert(cfg != NULL);
clock_timezone = cfg->timezone;
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 */
/* Note the ! up there btw. */
hook_table_apply(
NULL,
target,
"kernel32.dll",
clock_base_hook_syms,
_countof(clock_base_hook_syms));
}
if (cfg->timezone) {
if (clock_timezone) {
hook_table_apply(
NULL,
target,
"kernel32.dll",
clock_read_hook_syms,
_countof(clock_read_hook_syms));
}
if (!cfg->writeable) {
if (!clock_writeable) {
/* Install hook if this config parameter is FALSE! */
hook_table_apply(
NULL,
target,
"kernel32.dll",
clock_write_hook_syms,
_countof(clock_write_hook_syms));
}
return S_OK;
}

View File

@ -11,3 +11,4 @@ struct clock_config {
};
HRESULT clock_hook_init(const struct clock_config *cfg);
void clock_hook_insert_hooks(HMODULE target);