diff --git a/common/platform/config.c b/common/platform/config.c index e707126..62cf167 100644 --- a/common/platform/config.c +++ b/common/platform/config.c @@ -168,6 +168,8 @@ void misc_config_load(struct misc_config *cfg, const wchar_t *filename) assert(filename != NULL); cfg->enable = GetPrivateProfileIntW(L"misc", L"enable", 1, filename); + cfg->allowMasterKeyWrite = GetPrivateProfileIntW(L"misc", L"allowMasterKeyWrite", 0, filename); + cfg->allowReboot = GetPrivateProfileIntW(L"misc", L"allowReboot", 0, filename); } void netenv_config_load(struct netenv_config *cfg, const wchar_t *filename) diff --git a/common/platform/misc.c b/common/platform/misc.c index 31a4d16..9ede751 100644 --- a/common/platform/misc.c +++ b/common/platform/misc.c @@ -118,11 +118,13 @@ HRESULT misc_hook_init(const struct misc_config *cfg, const char *platform_id) return hr; } - hr = reg_hook_push_key( - HKEY_LOCAL_MACHINE, - L"SYSTEM\\SEGA\\SystemProperty\\Master", - misc_master_keys, - _countof(misc_master_keys)); + if (!cfg->allowMasterKeyWrite) { + hr = reg_hook_push_key( + HKEY_LOCAL_MACHINE, + L"SYSTEM\\SEGA\\SystemProperty\\Master", + misc_master_keys, + _countof(misc_master_keys)); + } if (FAILED(hr)) { return hr; @@ -130,7 +132,9 @@ HRESULT misc_hook_init(const struct misc_config *cfg, const char *platform_id) /* Apply function hooks */ - hook_table_apply(NULL, "user32.dll", misc_syms, _countof(misc_syms)); + if (!cfg->allowReboot) { + hook_table_apply(NULL, "user32.dll", misc_syms, _countof(misc_syms)); + } return S_OK; } diff --git a/common/platform/misc.h b/common/platform/misc.h index ce4aec4..e9695bc 100644 --- a/common/platform/misc.h +++ b/common/platform/misc.h @@ -1,9 +1,13 @@ #pragma once #include +#include +#include struct misc_config { bool enable; + bool allowReboot; + bool allowMasterKeyWrite; }; HRESULT misc_hook_init(const struct misc_config *cfg, const char *platform_id); diff --git a/doc/config/common.md b/doc/config/common.md index a9df591..3e475b8 100644 --- a/doc/config/common.md +++ b/doc/config/common.md @@ -744,4 +744,20 @@ Example for redirecting COM 5 to COM 10: ``` redirection0from=\\.\COM5 redirection0to=\\.\COM10 -``` \ No newline at end of file +``` + +## `[misc]` + +Configure miscellaneous hooks and features. + +### `allowMasterKeyWrite` + +Default: `0` + +Allows the game to write to specific registry keys relevant for the boot process. Only intended for owners of real hardware. + +### `allowReboot` + +Default: `0` + +Allows the game to reboot the computer. Only intended for owners of real hardware.