From f72a0380d201605646e980e638648689178a0353 Mon Sep 17 00:00:00 2001 From: henrypp Date: Thu, 30 Nov 2023 03:12:28 +0600 Subject: [PATCH] fix #1648 --- src/helper.c | 23 +++++++++-------------- src/wfp.c | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/helper.c b/src/helper.c index 47a88db1..056409aa 100644 --- a/src/helper.c +++ b/src/helper.c @@ -2041,16 +2041,16 @@ HBITMAP _app_bitmapfrompng ( BOOLEAN _app_wufixenabled () { WCHAR file_path[256]; - BOOLEAN is_enabled; - _r_str_printf (file_path, RTL_NUMBER_OF (file_path), L"%s\\wusvc.exe", _r_sys_getsystemdirectory ()->buffer); + if (!_r_config_getboolean (L"IsWUFixEnabled", FALSE)) + return FALSE; - is_enabled = _r_config_getboolean (L"IsWUFixEnabled", FALSE); + _r_str_printf (file_path, RTL_NUMBER_OF (file_path), L"%s\\wusvc.exe", _r_sys_getsystemdirectory ()->buffer); - if (is_enabled) - is_enabled = _r_fs_exists (file_path); + if (_r_fs_exists (file_path)) + return TRUE; - return is_enabled; + return FALSE; } VOID _app_wufixhelper ( @@ -2069,12 +2069,7 @@ VOID _app_wufixhelper ( BOOLEAN is_enabled = FALSE; NTSTATUS status; - _r_str_printf ( - reg_key, - RTL_NUMBER_OF (reg_key), - L"SYSTEM\\CurrentControlSet\\Services\\%s", - service_name - ); + _r_str_printf (reg_key, RTL_NUMBER_OF (reg_key), L"SYSTEM\\CurrentControlSet\\Services\\%s", service_name); status = _r_reg_openkey (HKEY_LOCAL_MACHINE, reg_key, KEY_READ | KEY_WRITE, &hkey); @@ -2106,7 +2101,7 @@ VOID _app_wufixhelper ( // restart service if (is_enable != is_enabled) { - hsvc = OpenService (hsvcmgr, service_name, SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS); + hsvc = OpenServiceW (hsvcmgr, service_name, SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS); if (hsvc) { @@ -2137,7 +2132,7 @@ VOID _app_wufixenable ( _r_str_printf (buffer1, RTL_NUMBER_OF (buffer1), L"%s\\svchost.exe", _r_sys_getsystemdirectory ()->buffer); _r_str_printf (buffer2, RTL_NUMBER_OF (buffer2), L"%s\\wusvc.exe", _r_sys_getsystemdirectory ()->buffer); - hsvcmgr = OpenSCManager (NULL, NULL, SC_MANAGER_CONNECT | SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS); + hsvcmgr = OpenSCManagerW (NULL, NULL, SC_MANAGER_CONNECT | SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS); if (!hsvcmgr) return; diff --git a/src/wfp.c b/src/wfp.c index 624350cf..da91852f 100644 --- a/src/wfp.c +++ b/src/wfp.c @@ -2634,7 +2634,7 @@ VOID NTAPI _wfp_applythread ( if (context->is_install) { if (_r_sys_isosversiongreaterorequal (WINDOWS_10)) - _app_wufixenable (context->hwnd, _app_wufixenabled ()); + _app_wufixenable (context->hwnd, _r_config_getboolean (L"IsWUFixEnabled", FALSE)); if (_wfp_initialize (context->hwnd, engine_handle)) _wfp_installfilters (engine_handle);