From cac83be05fe8e3452d375a98db0b7fbc7e340f8c Mon Sep 17 00:00:00 2001 From: henrypp Date: Wed, 22 Apr 2020 18:44:03 +0600 Subject: [PATCH] added temporary rules mode whether is active until reboot(fix #576) --- src/main.cpp | 210 +++++++++++++++++++++++++-------------------------- src/main.hpp | 10 ++- src/wfp.cpp | 103 ++++++++++++++++--------- src/wfp.hpp | 6 +- 4 files changed, 182 insertions(+), 147 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e3116fb7..8ae24566 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -237,23 +237,24 @@ void addcolor (UINT locale_id, LPCWSTR config_name, bool is_enabled, LPCWSTR con ptr_clr->locale_id = locale_id; ptr_clr->is_enabled = is_enabled; - colors.push_back (_r_obj_allocate (ptr_clr, &_app_dereferencecolor)); + colors.push_back (ptr_clr); } bool _app_installmessage (HWND hwnd, bool is_install) { WCHAR flag[64] = {0}; - WCHAR button_text_1[128] = {0}; - WCHAR button_text_2[128] = {0}; + WCHAR button_text_1[64] = {0}; + WCHAR button_text_2[64] = {0}; + + WCHAR radio_text_1[128] = {0}; + WCHAR radio_text_2[128] = {0}; WCHAR main[256] = {0}; - INT result = 0; - BOOL is_flagchecked = FALSE; - TASKDIALOGCONFIG tdc = {0}; - TASKDIALOG_BUTTON td_buttons[2] = {0}; + TASKDIALOG_BUTTON td_buttons[2]; + TASKDIALOG_BUTTON td_radios[2]; tdc.cbSize = sizeof (tdc); tdc.dwFlags = TDF_ENABLE_HYPERLINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_NO_SET_FOREGROUND; @@ -265,12 +266,11 @@ bool _app_installmessage (HWND hwnd, bool is_install) tdc.pszVerificationText = flag; tdc.pfCallback = &_r_msg_callback; tdc.lpCallbackData = MAKELONG (0, TRUE); // on top - tdc.cButtons = _countof (td_buttons); tdc.pButtons = td_buttons; + tdc.cButtons = _countof (td_buttons); - _r_str_copy (button_text_1, _countof (button_text_1), app.LocaleString (is_install ? IDS_TRAY_START : IDS_TRAY_STOP, nullptr)); - _r_str_copy (button_text_2, _countof (button_text_2), app.LocaleString (IDS_CLOSE, nullptr)); + tdc.nDefaultButton = IDYES; td_buttons[0].nButtonID = IDYES; td_buttons[0].pszButtonText = button_text_1; @@ -278,13 +278,28 @@ bool _app_installmessage (HWND hwnd, bool is_install) td_buttons[1].nButtonID = IDNO; td_buttons[1].pszButtonText = button_text_2; - tdc.nDefaultButton = is_install ? IDYES : IDNO; + _r_str_copy (button_text_1, _countof (button_text_1), app.LocaleString (is_install ? IDS_TRAY_START : IDS_TRAY_STOP, nullptr)); + _r_str_copy (button_text_2, _countof (button_text_2), app.LocaleString (IDS_CLOSE, nullptr)); if (is_install) { _r_str_copy (main, _countof (main), app.LocaleString (IDS_QUESTION_START, nullptr)); _r_str_copy (flag, _countof (flag), app.LocaleString (IDS_DISABLEWINDOWSFIREWALL_CHK, nullptr)); + tdc.pRadioButtons = td_radios; + tdc.cRadioButtons = _countof (td_radios); + + tdc.nDefaultRadioButton = IDYES; + + td_radios[0].nButtonID = IDYES; + td_radios[0].pszButtonText = radio_text_1; + + td_radios[1].nButtonID = IDNO; + td_radios[1].pszButtonText = radio_text_2; + + _r_str_copy (radio_text_1, _countof (radio_text_1), app.LocaleString (IDS_INSTALL_PERMANENT, nullptr)); + _r_str_copy (radio_text_2, _countof (radio_text_2), app.LocaleString (IDS_INSTALL_TEMPORARY, nullptr)); + if (app.ConfigGet (L"IsDisableWindowsFirewallChecked", true).AsBool ()) tdc.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED; } @@ -297,12 +312,18 @@ bool _app_installmessage (HWND hwnd, bool is_install) tdc.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED; } - if (_r_msg_taskdialog (&tdc, &result, nullptr, &is_flagchecked)) + INT message_code; + INT radio_code; + BOOL is_flagchecked; + + if (_r_msg_taskdialog (&tdc, &message_code, &radio_code, &is_flagchecked)) { - if (result == IDYES) + if (message_code == IDYES) { if (is_install) { + config.is_filterstemporary = (radio_code == IDNO); + app.ConfigSet (L"IsDisableWindowsFirewallChecked", is_flagchecked ? true : false); if (is_flagchecked) @@ -690,30 +711,18 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam INT item = 0; - for (size_t i = 0; i < colors.size (); i++) + for (auto &ptr_clr : colors) { - PR_OBJECT ptr_color_object = _r_obj_reference (colors.at (i)); + ptr_clr->new_clr = app.ConfigGet (ptr_clr->pcfg_value, ptr_clr->default_clr, L"colors").AsUlong (); - if (ptr_color_object) - { - PITEM_COLOR ptr_clr = (PITEM_COLOR)ptr_color_object->pdata; + _r_fastlock_acquireshared (&lock_checkbox); - if (ptr_clr) - { - ptr_clr->new_clr = app.ConfigGet (ptr_clr->pcfg_value, ptr_clr->default_clr, L"colors").AsUlong (); + _r_listview_additem (hwnd, IDC_COLORS, item, 0, app.LocaleString (ptr_clr->locale_id, nullptr), config.icon_id, I_GROUPIDNONE, (LPARAM)ptr_clr); + _r_listview_setitemcheck (hwnd, IDC_COLORS, item, app.ConfigGet (ptr_clr->pcfg_name, ptr_clr->is_enabled, L"colors").AsBool ()); - _r_fastlock_acquireshared (&lock_checkbox); + _r_fastlock_releaseshared (&lock_checkbox); - _r_listview_additem (hwnd, IDC_COLORS, item, 0, app.LocaleString (ptr_clr->locale_id, nullptr), config.icon_id, I_GROUPIDNONE, i); - _r_listview_setitemcheck (hwnd, IDC_COLORS, item, app.ConfigGet (ptr_clr->pcfg_name, ptr_clr->is_enabled, L"colors").AsBool ()); - - _r_fastlock_releaseshared (&lock_checkbox); - - item += 1; - } - - _r_obj_dereference (ptr_color_object); - } + item += 1; } break; @@ -857,21 +866,13 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam for (INT i = 0; i < _r_listview_getitemcount (hwnd, IDC_COLORS); i++) { - const size_t clr_idx = _r_listview_getitemlparam (hwnd, IDC_COLORS, i); - PR_OBJECT ptr_clr_object = _r_obj_reference (colors.at (clr_idx)); + PITEM_COLOR ptr_clr = (PITEM_COLOR)_r_listview_getitemlparam (hwnd, IDC_COLORS, i); - if (ptr_clr_object) + if (ptr_clr) { - PITEM_COLOR ptr_clr = (PITEM_COLOR)ptr_clr_object->pdata; - - if (ptr_clr) - { - _r_fastlock_acquireshared (&lock_checkbox); - _r_listview_setitem (hwnd, IDC_COLORS, i, 0, app.LocaleString (ptr_clr->locale_id, nullptr)); - _r_fastlock_releaseshared (&lock_checkbox); - } - - _r_obj_dereference (ptr_clr_object); + _r_fastlock_acquireshared (&lock_checkbox); + _r_listview_setitem (hwnd, IDC_COLORS, i, 0, app.LocaleString (ptr_clr->locale_id, nullptr)); + _r_fastlock_releaseshared (&lock_checkbox); } } @@ -990,17 +991,11 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam const bool is_enabled = (lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (2); - const size_t idx = lpnmlv->lParam; - PR_OBJECT ptr_clr_object = _r_obj_reference (colors.at (idx)); + PITEM_COLOR ptr_clr = (PITEM_COLOR)lpnmlv->lParam; - if (ptr_clr_object) + if (ptr_clr) { - PITEM_COLOR ptr_clr = (PITEM_COLOR)ptr_clr_object->pdata; - - if (ptr_clr) - app.ConfigSet (ptr_clr->pcfg_name, is_enabled, L"colors"); - - _r_obj_dereference (ptr_clr_object); + app.ConfigSet (ptr_clr->pcfg_name, is_enabled, L"colors"); _r_listview_redraw (app.GetHWND (), (INT)_r_tab_getlparam (app.GetHWND (), IDC_TAB, INVALID_INT)); } @@ -1030,13 +1025,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam if (listview_id == IDC_COLORS) { - const size_t idx = _r_listview_getitemlparam (hwnd, listview_id, lpnmlv->iItem); - PR_OBJECT ptr_clr_object_current = _r_obj_reference (colors.at (idx)); - - if (!ptr_clr_object_current) - break; - - PITEM_COLOR ptr_clr_current = (PITEM_COLOR)ptr_clr_object_current->pdata; + PITEM_COLOR ptr_clr_current = (PITEM_COLOR)_r_listview_getitemlparam (hwnd, listview_id, lpnmlv->iItem); if (ptr_clr_current) { @@ -1045,19 +1034,10 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam size_t index = 0; - for (auto &p : colors) + for (auto &ptr_clr : colors) { - PR_OBJECT ptr_clr_object = _r_obj_reference (p); - - if (ptr_clr_object) - { - PITEM_COLOR ptr_clr = (PITEM_COLOR)ptr_clr_object->pdata; - - if (ptr_clr) - cust[index++] = ptr_clr->default_clr; - - _r_obj_dereference (ptr_clr_object); - } + if (ptr_clr) + cust[index++] = ptr_clr->default_clr; } cc.lStructSize = sizeof (cc); @@ -1075,8 +1055,6 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam _r_listview_redraw (app.GetHWND (), (INT)_r_tab_getlparam (app.GetHWND (), IDC_TAB, INVALID_INT)); } } - - _r_obj_dereference (ptr_clr_object_current); } break; @@ -1457,14 +1435,14 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam app.ConfigSet (L"IsExcludeCustomRules", !!(IsDlgButtonChecked (hwnd, ctrl_id) == BST_CHECKED)); break; } - } + } break; - } } + } return FALSE; - } +} void _app_resizewindow (HWND hwnd, LPARAM lparam) { @@ -2020,16 +1998,23 @@ find_wrap: _r_createthread (&NetworkMonitorThread, (LPVOID)hwnd, false, THREAD_PRIORITY_LOWEST); // install filters - if (_wfp_isfiltersinstalled ()) { - //if (app.ConfigGet (L"IsDisableWindowsFirewallChecked", true).AsBool ()) - // _mps_changeconfig2 (false); + EnumInstall install_type = _wfp_isfiltersinstalled (); - _app_changefilters (hwnd, true, true); - } - else - { - _r_status_settext (hwnd, IDC_STATUSBAR, 0, app.LocaleString (IDS_STATUS_FILTERS_INACTIVE, nullptr)); + if (install_type != InstallDisabled) + { + if (install_type == InstallEnabledTemporary) + config.is_filterstemporary = true; + + //if (app.ConfigGet (L"IsDisableWindowsFirewallChecked", true).AsBool ()) + // _mps_changeconfig2 (false); + + _app_changefilters (hwnd, true, true); + } + else + { + _r_status_settext (hwnd, IDC_STATUSBAR, 0, app.LocaleString (_app_getinterfacestatelocale (install_type), nullptr)); + } } // set column size when "auto-size" option are disabled @@ -2861,7 +2846,6 @@ find_wrap: { SetMenuDefaultItem (hsubmenu, IDM_EXPLORE, FALSE); - const bool is_filtersinstalled = _wfp_isfiltersinstalled (); const time_t current_time = _r_unixtime_now (); #define RULES_ID 2 @@ -3053,7 +3037,7 @@ find_wrap: #define LOGGING_ID 5 #define ERRLOG_ID 6 - const bool is_filtersinstalled = _wfp_isfiltersinstalled (); + const bool is_filtersinstalled = (_wfp_isfiltersinstalled () != InstallDisabled); const HMENU hmenu = LoadMenu (nullptr, MAKEINTRESOURCE (IDM_TRAY)); const HMENU hsubmenu = GetSubMenu (hmenu, 0); @@ -3985,7 +3969,7 @@ find_wrap: if (_wfp_isfiltersapplying ()) break; - const bool is_filtersinstalled = !_wfp_isfiltersinstalled (); + const bool is_filtersinstalled = !(_wfp_isfiltersinstalled () != InstallDisabled); if (_app_installmessage (hwnd, is_filtersinstalled)) _app_changefilters (hwnd, is_filtersinstalled, true); @@ -4949,6 +4933,7 @@ INT APIENTRY wWinMain (HINSTANCE, HINSTANCE, LPWSTR, INT) bool is_install = false; bool is_uninstall = false; bool is_silent = false; + bool is_temporary = false; for (INT i = 0; i < numargs; i++) { @@ -4960,35 +4945,48 @@ INT APIENTRY wWinMain (HINSTANCE, HINSTANCE, LPWSTR, INT) else if (_r_str_compare (arga[i], L"/silent", 7) == 0) is_silent = true; + + else if (_r_str_compare (arga[i], L"/temp", 5) == 0) + is_temporary = true; } SAFE_LOCAL_FREE (arga); - if ((is_install || is_uninstall) && _r_sys_iselevated ()) + if (is_install || is_uninstall) { - _app_initialize (); - - if (is_install) + if (_r_sys_iselevated ()) { - if (is_silent || (!_wfp_isfiltersinstalled () && _app_installmessage (nullptr, true))) + _app_initialize (); + + if (is_install) { - _app_profile_load (nullptr); + if (is_silent || ((_wfp_isfiltersinstalled () == InstallDisabled) && _app_installmessage (nullptr, true))) + { + if (is_temporary) + config.is_filterstemporary = true; - if (_wfp_initialize (true)) - _wfp_installfilters (); + _app_profile_load (nullptr); - _wfp_uninitialize (false); + if (_wfp_initialize (true)) + _wfp_installfilters (); + + _wfp_uninitialize (false); + } + } + else if (is_uninstall) + { + if (is_silent || ((_wfp_isfiltersinstalled () != InstallDisabled) && _app_installmessage (nullptr, false))) + { + if (_wfp_initialize (false)) + _wfp_destroyfilters (_wfp_getenginehandle ()); + + _wfp_uninitialize (true); + } } } - else if (is_uninstall) + else { - if (is_silent || (_wfp_isfiltersinstalled () && _app_installmessage (nullptr, false))) - { - if (_wfp_initialize (false)) - _wfp_destroyfilters (_wfp_getenginehandle ()); - - _wfp_uninitialize (true); - } + return ERROR_ACCESS_DENIED; } return ERROR_SUCCESS; diff --git a/src/main.hpp b/src/main.hpp index b3459836..7270dbb2 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -88,10 +88,17 @@ enum EnumInfo InfoIconId, InfoUndeletable, InfoSilent, - InfoClearIds, + //InfoClearIds, InfoListviewId, }; +enum EnumInstall +{ + InstallDisabled = 0, + InstallEnabled = 1, + InstallEnabledTemporary = 2, +}; + // config #define LANG_MENU 6 #define UID 1984 // if you want to keep a secret, you must also hide it from yourself. @@ -286,6 +293,7 @@ struct STATIC_DATA bool is_notifytimeout = false; bool is_notifymouse = false; bool is_neteventset = false; + bool is_filterstemporary = false; }; typedef struct tagITEM_APP diff --git a/src/wfp.cpp b/src/wfp.cpp index 99a981a6..329680c3 100644 --- a/src/wfp.cpp +++ b/src/wfp.cpp @@ -8,49 +8,58 @@ bool _wfp_isfiltersapplying () return _r_fastlock_islocked (&lock_apply) || _r_fastlock_islocked (&lock_transaction); } -bool _wfp_isproviderinstalled () +EnumInstall _wfp_isproviderinstalled (HANDLE hengine) { - HKEY hkey = nullptr; + FWPM_PROVIDER *ptr_provider; + DWORD code = FwpmProviderGetByKey (hengine, &GUID_WfpProvider, &ptr_provider); - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\services\\BFE\\Parameters\\Policy\\Persistent\\Provider", 0, KEY_READ, &hkey) == ERROR_SUCCESS) + //if (code == ERROR_ACCESS_DENIED) // possible restriction + // return InstallEnabled; + + if (code == ERROR_SUCCESS) { - static const rstring guidString = _r_str_fromguid (GUID_WfpProvider); + EnumInstall result = ((ptr_provider->flags & FWPM_PROVIDER_FLAG_PERSISTENT) != 0) ? InstallEnabled : InstallEnabledTemporary; - if (RegQueryValueEx (hkey, guidString.GetString (), nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) - { - RegCloseKey (hkey); - return true; - } - - RegCloseKey (hkey); + FwpmFreeMemory ((void**)&ptr_provider); + return result; } - return false; + return InstallDisabled; } -bool _wfp_issublayerinstalled () +EnumInstall _wfp_issublayerinstalled (HANDLE hengine) { - HKEY hkey = nullptr; + FWPM_SUBLAYER *ptr_sublayer; + DWORD code = FwpmSubLayerGetByKey (hengine, &GUID_WfpSublayer, &ptr_sublayer); - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\services\\BFE\\Parameters\\Policy\\Persistent\\SubLayer", 0, KEY_READ, &hkey) == ERROR_SUCCESS) + //if (code == ERROR_ACCESS_DENIED) // possible restriction + // return InstallEnabled; + + if (code == ERROR_SUCCESS) { - static const rstring guidString = _r_str_fromguid (GUID_WfpSublayer); + EnumInstall result = ((ptr_sublayer->flags & FWPM_SUBLAYER_FLAG_PERSISTENT) != 0) ? InstallEnabled : InstallEnabledTemporary; - if (RegQueryValueEx (hkey, guidString.GetString (), nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) - { - RegCloseKey (hkey); - return true; - } - - RegCloseKey (hkey); + FwpmFreeMemory ((void**)&ptr_sublayer); + return result; } - return false; + return InstallDisabled; } -bool _wfp_isfiltersinstalled () +EnumInstall _wfp_isfiltersinstalled () { - return _wfp_isproviderinstalled () && _wfp_issublayerinstalled (); + HANDLE hengine_temp; + DWORD code = FwpmEngineOpen (nullptr, RPC_C_AUTHN_WINNT, nullptr, nullptr, &hengine_temp); + + if (code == ERROR_SUCCESS) + { + EnumInstall result = _wfp_issublayerinstalled (hengine_temp); + + FwpmEngineClose (hengine_temp); + return result; + } + + return InstallDisabled; } HANDLE& _wfp_getenginehandle () @@ -114,7 +123,7 @@ bool _wfp_initialize (bool is_full) const size_t count = 2; EXPLICIT_ACCESS access[count] = {{0}}; - RtlSecureZeroMemory (access, count * sizeof (EXPLICIT_ACCESS)); + RtlSecureZeroMemory (access, sizeof (access)); // create default (engine) acl access[0].grfAccessPermissions = FWPM_GENERIC_ALL | DELETE | WRITE_DAC | WRITE_OWNER; @@ -173,8 +182,8 @@ bool _wfp_initialize (bool is_full) } // install engine provider and it's sublayer - bool is_providerexist = _wfp_isproviderinstalled (); - bool is_sublayerexist = _wfp_issublayerinstalled (); + bool is_providerexist = (_wfp_isproviderinstalled (config.hengine) != InstallDisabled); + bool is_sublayerexist = (_wfp_issublayerinstalled (config.hengine) != InstallDisabled); if (is_full) { @@ -191,7 +200,9 @@ bool _wfp_initialize (bool is_full) provider.displayData.description = APP_NAME; provider.providerKey = GUID_WfpProvider; - provider.flags = FWPM_PROVIDER_FLAG_PERSISTENT; + + if (!config.is_filterstemporary) + provider.flags = FWPM_PROVIDER_FLAG_PERSISTENT; rc = FwpmProviderAdd (config.hengine, &provider, nullptr); @@ -223,9 +234,11 @@ bool _wfp_initialize (bool is_full) sublayer.providerKey = const_cast(&GUID_WfpProvider); sublayer.subLayerKey = GUID_WfpSublayer; - sublayer.flags = FWPM_SUBLAYER_FLAG_PERSISTENT; sublayer.weight = (UINT16)app.ConfigGet (L"SublayerWeight", SUBLAYER_WEIGHT_DEFAULT).AsUint (); // highest weight for UINT16 + if (!config.is_filterstemporary) + sublayer.flags = FWPM_SUBLAYER_FLAG_PERSISTENT; + rc = FwpmSubLayerAdd (config.hengine, &sublayer, nullptr); if (rc != ERROR_SUCCESS && rc != FWP_E_ALREADY_EXISTS) @@ -660,7 +673,7 @@ DWORD _wfp_createfilter (HANDLE hengine, LPCWSTR name, FWPM_FILTER_CONDITION* lp _r_str_copy (fltr_name, _countof (fltr_name), APP_NAME); WCHAR fltr_desc[128] = {0}; - _r_str_copy (fltr_desc, _countof (fltr_desc), _r_str_isempty (name) ? APP_NAME : name); + _r_str_copy (fltr_desc, _countof (fltr_desc), _r_str_isempty (name) ? SZ_EMPTY : name); filter.displayData.name = fltr_name; filter.displayData.description = fltr_desc; @@ -668,7 +681,8 @@ DWORD _wfp_createfilter (HANDLE hengine, LPCWSTR name, FWPM_FILTER_CONDITION* lp // set filter flags if ((flags & FWPM_FILTER_FLAG_BOOTTIME) == 0) { - filter.flags = FWPM_FILTER_FLAG_PERSISTENT; + if (!config.is_filterstemporary) + filter.flags = FWPM_FILTER_FLAG_PERSISTENT; // filter is indexed to help enable faster lookup during classification (win8+) if (_r_sys_validversion (6, 2)) @@ -699,7 +713,7 @@ DWORD _wfp_createfilter (HANDLE hengine, LPCWSTR name, FWPM_FILTER_CONDITION* lp filter.action.type = action; - UINT64 filter_id = 0; + UINT64 filter_id; const DWORD rc = FwpmFilterAdd (hengine, &filter, nullptr, &filter_id); if (rc == ERROR_SUCCESS) @@ -709,7 +723,7 @@ DWORD _wfp_createfilter (HANDLE hengine, LPCWSTR name, FWPM_FILTER_CONDITION* lp } else { - app.LogError (L"FwpmFilterAdd", rc, name, UID); + app.LogError (L"FwpmFilterAdd", rc, fltr_desc, UID); } return rc; @@ -724,7 +738,22 @@ void _wfp_clearfilter_ids () // clear apps filters for (auto &p : apps) - _app_setappinfo (p.first, InfoClearIds, 0); + { + PR_OBJECT ptr_app_object = _r_obj_reference (p.second); + + if (!ptr_app_object) + continue; + + PITEM_APP ptr_app = (PITEM_APP)ptr_app_object->pdata; + + if (ptr_app) + { + ptr_app->is_haveerrors = false; + ptr_app->guids.clear (); + } + + _r_obj_dereference (ptr_app_object); + } // clear rules filters for (auto &p : rules_arr) @@ -1624,7 +1653,7 @@ bool _wfp_create2filters (HANDLE hengine, UINT line, bool is_intransact) } // install boot-time filters (enforced at boot-time, even before "base filtering engine" service starts) - if (app.ConfigGet (L"InstallBoottimeFilters", true).AsBool ()) + if (app.ConfigGet (L"InstallBoottimeFilters", true).AsBool () && !config.is_filterstemporary) { fwfc[0].fieldKey = FWPM_CONDITION_FLAGS; fwfc[0].matchType = FWP_MATCH_FLAGS_ALL_SET; diff --git a/src/wfp.hpp b/src/wfp.hpp index bbfeaf12..7f237d3f 100644 --- a/src/wfp.hpp +++ b/src/wfp.hpp @@ -3,11 +3,11 @@ #pragma once -bool _wfp_isproviderinstalled (); -bool _wfp_issublayerinstalled (); +EnumInstall _wfp_isproviderinstalled (HANDLE hengine); +EnumInstall _wfp_issublayerinstalled (HANDLE hengine); bool _wfp_isfiltersapplying (); -bool _wfp_isfiltersinstalled (); +EnumInstall _wfp_isfiltersinstalled (); HANDLE& _wfp_getenginehandle ();