1
0
mirror of https://gitea.tendokyu.moe/Hay1tsme/segatools.git synced 2024-11-24 17:30:11 +01:00

platform: Prevent amdaemon from shutting down the computer or logging off user

This commit is contained in:
Felix 2021-08-12 23:13:58 +00:00
parent cc95389646
commit ed42e63a78

View File

@ -5,16 +5,29 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "hook/table.h"
#include "hooklib/reg.h" #include "hooklib/reg.h"
#include "platform/misc.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_os_version(void *bytes, uint32_t *nbytes);
static HRESULT misc_read_app_loader_count(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_error(void *bytes, uint32_t *nbytes);
static HRESULT misc_read_cpu_temp_warning(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 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[] = { static const struct reg_hook_val misc_root_keys[] = {
{ {
.name = L"OSVersion", .name = L"OSVersion",
@ -109,9 +122,20 @@ HRESULT misc_hook_init(const struct misc_config *cfg, const char *platform_id)
return hr; return hr;
} }
/* Apply function hooks */
hook_table_apply(NULL, "user32.dll", misc_syms, _countof(misc_syms));
return S_OK; 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) static HRESULT misc_read_os_version(void *bytes, uint32_t *nbytes)
{ {
return reg_hook_read_wstr(bytes, nbytes, L"0_0_0"); return reg_hook_read_wstr(bytes, nbytes, L"0_0_0");