misc: add system version hook
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hook/table.h"
|
||||
#include "hooklib/reg.h"
|
||||
|
||||
#include "platform/misc.h"
|
||||
|
||||
@ -16,13 +17,14 @@ static BOOL WINAPI my_BlockInput(BOOL fBlockIt);
|
||||
static int WINAPI my_ShowCursor(BOOL bShow);
|
||||
static BOOL WINAPI my_GetCursorInfo(PCURSORINFO pci);
|
||||
|
||||
static HRESULT reg_read_sys_ver(void *bytes, uint32_t *nbytes);
|
||||
|
||||
static BOOL (WINAPI *next_BlockInput)(BOOL fBlockIt);
|
||||
static int (WINAPI *next_ShowCursor)(BOOL bShow);
|
||||
static BOOL (WINAPI *next_GetCursorInfo)(PCURSORINFO pci);
|
||||
|
||||
BOOL block_input_hook = true;
|
||||
BOOL show_cursor_hook = true;
|
||||
int real_cursor_state = 0;
|
||||
static struct misc_config config;
|
||||
static int real_cursor_state = 0;
|
||||
|
||||
static const struct hook_symbol misc_hook_syms[] = {
|
||||
{
|
||||
@ -40,12 +42,19 @@ static const struct hook_symbol misc_hook_syms[] = {
|
||||
}
|
||||
};
|
||||
|
||||
static const struct reg_hook_val nbgi_reg[] = {
|
||||
{
|
||||
.name = L"SystemVersion",
|
||||
.type = REG_SZ,
|
||||
.read = reg_read_sys_ver
|
||||
}
|
||||
};
|
||||
|
||||
HRESULT misc_hook_init(const struct misc_config *cfg)
|
||||
{
|
||||
assert(cfg != NULL);
|
||||
|
||||
show_cursor_hook = cfg->show_cursor_hook;
|
||||
block_input_hook = cfg->block_input_hook;
|
||||
memcpy(&config, cfg, sizeof(*cfg));
|
||||
|
||||
dprintf("Misc: init\n");
|
||||
|
||||
@ -55,12 +64,18 @@ HRESULT misc_hook_init(const struct misc_config *cfg)
|
||||
misc_hook_syms,
|
||||
_countof(misc_hook_syms));
|
||||
|
||||
reg_hook_push_key(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\NBGI",
|
||||
nbgi_reg,
|
||||
_countof(nbgi_reg));
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static BOOL WINAPI my_BlockInput(BOOL fBlockIt)
|
||||
{
|
||||
if (!block_input_hook) {
|
||||
if (!config.block_input_hook) {
|
||||
return next_BlockInput(fBlockIt);
|
||||
}
|
||||
|
||||
@ -71,7 +86,7 @@ static BOOL WINAPI my_BlockInput(BOOL fBlockIt)
|
||||
|
||||
static int WINAPI my_ShowCursor(BOOL bShow)
|
||||
{
|
||||
if (!show_cursor_hook) {
|
||||
if (!config.show_cursor_hook) {
|
||||
return next_ShowCursor(bShow);
|
||||
}
|
||||
|
||||
@ -87,7 +102,7 @@ static int WINAPI my_ShowCursor(BOOL bShow)
|
||||
|
||||
static BOOL WINAPI my_GetCursorInfo(PCURSORINFO pci)
|
||||
{
|
||||
if (!show_cursor_hook) {
|
||||
if (!config.show_cursor_hook) {
|
||||
return next_GetCursorInfo(pci);
|
||||
}
|
||||
|
||||
@ -103,4 +118,10 @@ static BOOL WINAPI my_GetCursorInfo(PCURSORINFO pci)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static HRESULT reg_read_sys_ver(void *bytes, uint32_t *nbytes)
|
||||
{
|
||||
dprintf("Misc: Get system version\n");
|
||||
return reg_hook_read_wstr(bytes, nbytes, config.system_version);
|
||||
}
|
Reference in New Issue
Block a user