From da6879606ae867f6f262d9548911dc8e72c1162f Mon Sep 17 00:00:00 2001 From: Felix Date: Thu, 12 Aug 2021 23:13:58 +0000 Subject: [PATCH] platform: Prevent amdaemon from shutting down the computer or logging off user --- platform/misc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/platform/misc.c b/platform/misc.c index f0feadf..f4bc87d 100644 --- a/platform/misc.c +++ b/platform/misc.c @@ -5,16 +5,29 @@ #include #include +#include "hook/table.h" + #include "hooklib/reg.h" #include "platform/misc.h" +#include "util/dprintf.h" + +static BOOL WINAPI misc_ExitWindowsEx(unsigned int flags, uint32_t reason); + static HRESULT misc_read_os_version(void *bytes, uint32_t *nbytes); static HRESULT misc_read_app_loader_count(void *bytes, uint32_t *nbytes); static HRESULT misc_read_cpu_temp_error(void *bytes, uint32_t *nbytes); static HRESULT misc_read_cpu_temp_warning(void *bytes, uint32_t *nbytes); static HRESULT misc_read_platform_id(void *bytes, uint32_t *nbytes); +static const struct hook_symbol misc_syms[] = { + { + .name = "ExitWindowsEx", + .patch = misc_ExitWindowsEx, + } +}; + static const struct reg_hook_val misc_root_keys[] = { { .name = L"OSVersion", @@ -109,9 +122,20 @@ HRESULT misc_hook_init(const struct misc_config *cfg, const char *platform_id) return hr; } + /* Apply function hooks */ + + hook_table_apply(NULL, "user32.dll", misc_syms, _countof(misc_syms)); + return S_OK; } +static BOOL WINAPI misc_ExitWindowsEx(unsigned int flags, uint32_t reason) +{ + dprintf("Misc: Blocked system reboot\n"); + + return TRUE; +} + static HRESULT misc_read_os_version(void *bytes, uint32_t *nbytes) { return reg_hook_read_wstr(bytes, nbytes, L"0_0_0");