From ced21e32f964e0211c5f9b3db14f1db6a03af688 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Mon, 18 Sep 2023 03:57:11 -0400 Subject: [PATCH] amcus: add proper disable option --- amcus/amcus.c | 20 +++++++++++++++----- amcus/amcus.h | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/amcus/amcus.c b/amcus/amcus.c index 98cdb24..9dbfd0a 100644 --- a/amcus/amcus.c +++ b/amcus/amcus.c @@ -12,6 +12,7 @@ #include "util/dprintf.h" // https://dev.s-ul.net/djhackers/bemanitools/-/blob/master/src/main/dinput/device_dinput8.c +static bool is_enable = false; static HRESULT STDAPICALLTYPE my_CoCreateInstance( const IID *const rclsid, @@ -46,17 +47,26 @@ HRESULT amcus_hook_init(struct amcus_config *cfg) return S_OK; } + is_enable = true; + dprintf("AMCUS: init\n"); - hook_table_apply( - NULL, - "ole32.dll", - amcus_hook_syms, - _countof(amcus_hook_syms)); + amcus_insert_hooks(NULL); return S_OK; } +void amcus_insert_hooks(HMODULE target) +{ + if (is_enable) { + hook_table_apply( + target, + "ole32.dll", + amcus_hook_syms, + _countof(amcus_hook_syms)); + } +} + static HRESULT STDAPICALLTYPE my_CoCreateInstance( const IID *const rclsid, LPUNKNOWN pUnkOuter, diff --git a/amcus/amcus.h b/amcus/amcus.h index 5f4b854..2211392 100644 --- a/amcus/amcus.h +++ b/amcus/amcus.h @@ -6,6 +6,7 @@ #include "amcus/iauth.h" HRESULT amcus_hook_init(struct amcus_config *cfg); +void amcus_insert_hooks(HMODULE target); DEFINE_GUID( amcus_rclsid,