118 lines
3.0 KiB
C
118 lines
3.0 KiB
C
#include <windows.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "hooklib/reg.h"
|
|
#include "platform/syscfg.h"
|
|
#include "platform/vfs.h"
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
static struct syscfg_config config;
|
|
static uint32_t game_id;
|
|
|
|
static HRESULT syscfg_game_kind(void *bytes, uint32_t *nbytes);
|
|
static HRESULT syscfg_evt_next_time(void *bytes, uint32_t *nbytes);
|
|
static HRESULT syscfg_condition_time(void *bytes, uint32_t *nbytes);
|
|
static HRESULT syscfg_traffic_ct(void *bytes, uint32_t *nbytes);
|
|
static HRESULT syscfg_log_level(void *bytes, uint32_t *nbytes);
|
|
static HRESULT syscfg_news_path(void *bytes, uint32_t *nbytes);
|
|
static HRESULT syscfg_event_path(void *bytes, uint32_t *nbytes);
|
|
static HRESULT syscfg_log_path(void *bytes, uint32_t *nbytes);
|
|
|
|
static const struct reg_hook_val fake_com_keys[] = {
|
|
{
|
|
.name = L"GameKind",
|
|
.read = syscfg_game_kind,
|
|
.type = REG_DWORD,
|
|
},{
|
|
.name = L"EventNextTime",
|
|
.read = syscfg_evt_next_time,
|
|
.type = REG_DWORD,
|
|
},{
|
|
.name = L"ConditionTime",
|
|
.read = syscfg_condition_time,
|
|
.type = REG_DWORD,
|
|
},{
|
|
.name = L"TrafficCount",
|
|
.read = syscfg_traffic_ct,
|
|
.type = REG_DWORD,
|
|
},{
|
|
.name = L"LogLevel",
|
|
.read = syscfg_log_level,
|
|
.type = REG_DWORD,
|
|
},{
|
|
.name = L"NewsPath",
|
|
.read = syscfg_news_path,
|
|
.type = REG_SZ,
|
|
},{
|
|
.name = L"EventPath",
|
|
.read = syscfg_event_path,
|
|
.type = REG_SZ,
|
|
},{
|
|
.name = L"LogPath",
|
|
.read = syscfg_log_path,
|
|
.type = REG_SZ,
|
|
},
|
|
};
|
|
|
|
HRESULT syscfg_hook_init(const struct syscfg_config *cfg, const uint32_t gid)
|
|
{
|
|
HRESULT hr;
|
|
if (!cfg->enable) {
|
|
return S_FALSE;
|
|
}
|
|
|
|
memcpy(&config, cfg, sizeof(*cfg));
|
|
game_id = gid;
|
|
|
|
hr = reg_hook_push_key(
|
|
HKEY_LOCAL_MACHINE,
|
|
L"SOFTWARE\\taito\\typex",
|
|
fake_com_keys,
|
|
_countof(fake_com_keys));
|
|
|
|
return hr;
|
|
}
|
|
|
|
static HRESULT syscfg_game_kind(void *bytes, uint32_t *nbytes)
|
|
{
|
|
return reg_hook_read_u32(bytes, nbytes, game_id);
|
|
}
|
|
|
|
static HRESULT syscfg_evt_next_time(void *bytes, uint32_t *nbytes)
|
|
{
|
|
return reg_hook_read_u32(bytes, nbytes, 1800);
|
|
}
|
|
|
|
static HRESULT syscfg_condition_time(void *bytes, uint32_t *nbytes)
|
|
{
|
|
return reg_hook_read_u32(bytes, nbytes, 1800);
|
|
}
|
|
|
|
static HRESULT syscfg_traffic_ct(void *bytes, uint32_t *nbytes)
|
|
{
|
|
return reg_hook_read_u32(bytes, nbytes, 0); // unused?
|
|
}
|
|
|
|
static HRESULT syscfg_log_level(void *bytes, uint32_t *nbytes)
|
|
{
|
|
return reg_hook_read_u32(bytes, nbytes, config.log_level);
|
|
}
|
|
|
|
static HRESULT syscfg_news_path(void *bytes, uint32_t *nbytes)
|
|
{
|
|
|
|
return reg_hook_read_wstr(bytes, nbytes, L"D:\\news");
|
|
}
|
|
|
|
static HRESULT syscfg_event_path(void *bytes, uint32_t *nbytes)
|
|
{
|
|
return reg_hook_read_wstr(bytes, nbytes, L"D:\\event");
|
|
}
|
|
|
|
static HRESULT syscfg_log_path(void *bytes, uint32_t *nbytes)
|
|
{
|
|
return reg_hook_read_wstr(bytes, nbytes, L"D:\\log");
|
|
}
|