mirror of
https://github.com/henrypp/simplewall.git
synced 2026-10-22 02:52:54 -05:00
code cosmetics
This commit is contained in:
10 files changed
+2018
-577
No files matched your search
+34
-26
@@ -1417,18 +1417,18 @@ INT_PTR CALLBACK EditorPagesProc (
|
||||
_r_obj_concatstrings (2, _r_locale_getstring (IDS_ADD), L"...")
|
||||
);
|
||||
|
||||
AppendMenu (hsubmenu, MF_STRING, id_add, localized_string->buffer);
|
||||
_r_menu_additem (hsubmenu, id_add, localized_string->buffer);
|
||||
|
||||
_r_obj_movereference (
|
||||
&localized_string,
|
||||
_r_obj_concatstrings (2, _r_locale_getstring (IDS_EDIT2), L"...")
|
||||
);
|
||||
|
||||
AppendMenu (hsubmenu, MF_STRING, id_edit, localized_string->buffer);
|
||||
_r_menu_additem (hsubmenu, id_edit, localized_string->buffer);
|
||||
|
||||
AppendMenu (hsubmenu, MF_STRING, id_delete, _r_locale_getstring (IDS_DELETE));
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_COPY, _r_locale_getstring (IDS_COPY));
|
||||
_r_menu_additem (hsubmenu, id_delete, _r_locale_getstring (IDS_DELETE));
|
||||
_r_menu_additem (hsubmenu, 0, NULL);
|
||||
_r_menu_additem (hsubmenu, IDM_COPY, _r_locale_getstring (IDS_COPY));
|
||||
|
||||
if (context->ptr_rule->is_readonly)
|
||||
{
|
||||
@@ -1448,10 +1448,10 @@ INT_PTR CALLBACK EditorPagesProc (
|
||||
}
|
||||
else if (listview_id == IDC_RULE_APPS_ID || listview_id == IDC_APP_RULES_ID)
|
||||
{
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_CHECK, _r_locale_getstring (IDS_CHECK));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_UNCHECK, _r_locale_getstring (IDS_UNCHECK));
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_COPY, _r_locale_getstring (IDS_COPY));
|
||||
_r_menu_additem (hsubmenu, IDM_CHECK, _r_locale_getstring (IDS_CHECK));
|
||||
_r_menu_additem (hsubmenu, IDM_UNCHECK, _r_locale_getstring (IDS_UNCHECK));
|
||||
_r_menu_additem (hsubmenu, 0, NULL);
|
||||
_r_menu_additem (hsubmenu, IDM_COPY, _r_locale_getstring (IDS_COPY));
|
||||
|
||||
if (context->is_settorules && context->ptr_rule->type != DATA_RULE_USER)
|
||||
{
|
||||
@@ -2036,11 +2036,7 @@ INT_PTR CALLBACK EditorProc (
|
||||
_r_locale_getstring (IDS_ENABLE_CHK)
|
||||
);
|
||||
|
||||
CheckDlgButton (
|
||||
hwnd,
|
||||
IDC_ENABLE_CHK,
|
||||
context->ptr_rule->is_enabled ? BST_CHECKED : BST_UNCHECKED
|
||||
);
|
||||
_r_ctrl_checkbutton (hwnd, IDC_ENABLE_CHK, !!(context->ptr_rule->is_enabled));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2075,11 +2071,7 @@ INT_PTR CALLBACK EditorProc (
|
||||
_r_locale_getstring (IDS_ENABLE_APP_CHK)
|
||||
);
|
||||
|
||||
CheckDlgButton (
|
||||
hwnd,
|
||||
IDC_ENABLE_CHK,
|
||||
context->ptr_app->is_enabled ? BST_CHECKED : BST_UNCHECKED
|
||||
);
|
||||
_r_ctrl_checkbutton (hwnd, IDC_ENABLE_CHK, !!(context->ptr_app->is_enabled));
|
||||
}
|
||||
|
||||
// initialize layout
|
||||
@@ -2252,6 +2244,7 @@ INT_PTR CALLBACK EditorProc (
|
||||
SIZE_T rule_idx;
|
||||
INT listview_id;
|
||||
INT item_id;
|
||||
INT check_id;
|
||||
BOOLEAN is_enable;
|
||||
|
||||
context = _app_editor_getcontext (hwnd);
|
||||
@@ -2341,16 +2334,25 @@ INT_PTR CALLBACK EditorProc (
|
||||
|
||||
_r_obj_movereference (&context->ptr_rule->protocol_str, string);
|
||||
|
||||
check_id = _r_ctrl_isradiochecked (
|
||||
hpage_general,
|
||||
IDC_RULE_DIRECTION_OUTBOUND,
|
||||
IDC_RULE_DIRECTION_ANY
|
||||
);
|
||||
|
||||
context->ptr_rule->direction = (FWP_DIRECTION)_r_calc_clamp (
|
||||
_r_ctrl_isradiobuttonchecked (hpage_general, IDC_RULE_DIRECTION_OUTBOUND, IDC_RULE_DIRECTION_ANY) - IDC_RULE_DIRECTION_OUTBOUND,
|
||||
check_id - IDC_RULE_DIRECTION_OUTBOUND,
|
||||
FWP_DIRECTION_OUTBOUND,
|
||||
FWP_DIRECTION_MAX
|
||||
);
|
||||
|
||||
if (_r_ctrl_isradiobuttonchecked (
|
||||
check_id = _r_ctrl_isradiochecked (
|
||||
hpage_general,
|
||||
IDC_RULE_ACTION_BLOCK,
|
||||
IDC_RULE_ACTION_ALLOW) == IDC_RULE_ACTION_BLOCK)
|
||||
IDC_RULE_ACTION_ALLOW
|
||||
);
|
||||
|
||||
if (check_id == IDC_RULE_ACTION_BLOCK)
|
||||
{
|
||||
context->ptr_rule->action = FWP_ACTION_BLOCK;
|
||||
}
|
||||
@@ -2361,8 +2363,14 @@ INT_PTR CALLBACK EditorProc (
|
||||
|
||||
if (context->ptr_rule->type == DATA_RULE_USER)
|
||||
{
|
||||
context->ptr_rule->weight = ((context->ptr_rule->action == FWP_ACTION_BLOCK) ?
|
||||
FW_WEIGHT_RULE_USER_BLOCK : FW_WEIGHT_RULE_USER);
|
||||
if (context->ptr_rule->action == FWP_ACTION_BLOCK)
|
||||
{
|
||||
context->ptr_rule->weight = FW_WEIGHT_RULE_USER_BLOCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
context->ptr_rule->weight = FW_WEIGHT_RULE_USER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2389,7 +2397,7 @@ INT_PTR CALLBACK EditorProc (
|
||||
// enable rule
|
||||
_app_ruleenable (
|
||||
context->ptr_rule,
|
||||
(IsDlgButtonChecked (hwnd, IDC_ENABLE_CHK) == BST_CHECKED),
|
||||
_r_ctrl_isbuttonchecked (hwnd, IDC_ENABLE_CHK),
|
||||
TRUE
|
||||
);
|
||||
|
||||
@@ -2402,7 +2410,7 @@ INT_PTR CALLBACK EditorProc (
|
||||
hpage_rule = (HWND)_r_tab_getitemlparam (hwnd, IDC_TAB, 1);
|
||||
|
||||
context->ptr_app->is_haveerrors = FALSE; // reset errors
|
||||
context->ptr_app->is_enabled = !!(IsDlgButtonChecked (hwnd, IDC_ENABLE_CHK) == BST_CHECKED);
|
||||
context->ptr_app->is_enabled = _r_ctrl_isbuttonchecked (hwnd, IDC_ENABLE_CHK);
|
||||
|
||||
rules = _r_obj_createlist (NULL);
|
||||
|
||||
|
||||
+13
-29
@@ -1253,7 +1253,6 @@ VOID _app_generate_rulescontrol (
|
||||
)
|
||||
{
|
||||
ITEM_STATUS status;
|
||||
MENUITEMINFO mii;
|
||||
WCHAR buffer[128];
|
||||
PITEM_RULE ptr_rule;
|
||||
SIZE_T limit_group;
|
||||
@@ -1265,9 +1264,7 @@ VOID _app_generate_rulescontrol (
|
||||
|
||||
if (!status.rules_count)
|
||||
{
|
||||
AppendMenu (hsubmenu, MF_STRING, IDX_RULES_SPECIAL, SZ_EMPTY);
|
||||
|
||||
_r_menu_enableitem (hsubmenu, IDX_RULES_SPECIAL, MF_BYCOMMAND, FALSE);
|
||||
_r_menu_additem_ex (hsubmenu, IDX_RULES_SPECIAL, SZ_EMPTY, MF_DISABLED);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1323,16 +1320,12 @@ VOID _app_generate_rulescontrol (
|
||||
if (ptr_rule->is_readonly)
|
||||
_r_str_append (buffer, RTL_NUMBER_OF (buffer), SZ_RULE_INTERNAL_MENU);
|
||||
|
||||
RtlZeroMemory (&mii, sizeof (mii));
|
||||
|
||||
mii.cbSize = sizeof (mii);
|
||||
mii.fMask = MIIM_ID | MIIM_FTYPE | MIIM_STATE | MIIM_STRING;
|
||||
mii.fType = MFT_STRING;
|
||||
mii.dwTypeData = buffer;
|
||||
mii.fState = (is_enabled ? MF_CHECKED : MF_UNCHECKED);
|
||||
mii.wID = IDX_RULES_SPECIAL + (UINT)i;
|
||||
|
||||
InsertMenuItem (hsubmenu, mii.wID, FALSE, &mii);
|
||||
_r_menu_additem_ex (
|
||||
hsubmenu,
|
||||
IDX_RULES_SPECIAL + (UINT)i,
|
||||
buffer,
|
||||
is_enabled ? MF_CHECKED : MF_UNCHECKED
|
||||
);
|
||||
|
||||
limit_group -= 1;
|
||||
}
|
||||
@@ -1341,12 +1334,12 @@ VOID _app_generate_rulescontrol (
|
||||
}
|
||||
|
||||
if (!type)
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
_r_menu_additem (hsubmenu, 0, NULL);
|
||||
}
|
||||
|
||||
if (ptr_log)
|
||||
{
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
_r_menu_additem (hsubmenu, 0, NULL);
|
||||
|
||||
_r_str_printf (
|
||||
buffer,
|
||||
@@ -1355,21 +1348,12 @@ VOID _app_generate_rulescontrol (
|
||||
_r_obj_getstring (ptr_log->remote_addr_str)
|
||||
);
|
||||
|
||||
RtlZeroMemory (&mii, sizeof (mii));
|
||||
|
||||
mii.cbSize = sizeof (mii);
|
||||
mii.fMask = MIIM_ID | MIIM_FTYPE | MIIM_STATE | MIIM_STRING;
|
||||
mii.fType = MFT_STRING;
|
||||
mii.dwTypeData = buffer;
|
||||
mii.fState = MF_UNCHECKED;
|
||||
mii.wID = IDX_RULES_SPECIAL + (UINT)i + 1;
|
||||
|
||||
InsertMenuItem (hsubmenu, mii.wID, FALSE, &mii);
|
||||
_r_menu_additem (hsubmenu, IDX_RULES_SPECIAL + (UINT)i + 1, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_OPENRULESEDITOR, _r_locale_getstring (IDS_OPENRULESEDITOR));
|
||||
_r_menu_additem (hsubmenu, 0, NULL);
|
||||
_r_menu_additem (hsubmenu, IDM_OPENRULESEDITOR, _r_locale_getstring (IDS_OPENRULESEDITOR));
|
||||
}
|
||||
|
||||
VOID _app_generate_timerscontrol (
|
||||
@@ -1401,7 +1385,7 @@ VOID _app_generate_timerscontrol (
|
||||
|
||||
index = IDX_TIMER + (UINT)i;
|
||||
|
||||
AppendMenu (hsubmenu, MF_STRING, index, interval_string->buffer);
|
||||
_r_menu_additem (hsubmenu, index, interval_string->buffer);
|
||||
|
||||
if (!is_checked && (app_time > current_time) && (app_time <= (current_time + timestamp)))
|
||||
{
|
||||
|
||||
+28
-4
@@ -19,7 +19,13 @@ PICON_INFORMATION _app_icons_getdefault ()
|
||||
L"\\svchost.exe"
|
||||
);
|
||||
|
||||
_app_icons_loadfromfile (path, 0, &icon_info.app_icon_id, &icon_info.app_hicon, FALSE);
|
||||
_app_icons_loadfromfile (
|
||||
path,
|
||||
0,
|
||||
&icon_info.app_icon_id,
|
||||
&icon_info.app_hicon,
|
||||
FALSE
|
||||
);
|
||||
|
||||
// load default service icons
|
||||
_r_obj_dereference (path);
|
||||
@@ -30,7 +36,13 @@ PICON_INFORMATION _app_icons_getdefault ()
|
||||
L"\\shell32.dll"
|
||||
);
|
||||
|
||||
_app_icons_loadfromfile (path, 0, &icon_info.service_icon_id, &icon_info.service_hicon, FALSE);
|
||||
_app_icons_loadfromfile (
|
||||
path,
|
||||
0,
|
||||
&icon_info.service_icon_id,
|
||||
&icon_info.service_hicon,
|
||||
FALSE
|
||||
);
|
||||
|
||||
// load uwp icons
|
||||
if (_r_sys_isosversiongreaterorequal (WINDOWS_8))
|
||||
@@ -43,7 +55,13 @@ PICON_INFORMATION _app_icons_getdefault ()
|
||||
L"\\wsreset.exe"
|
||||
);
|
||||
|
||||
_app_icons_loadfromfile (path, 0, &icon_info.uwp_icon_id, &icon_info.uwp_hicon, FALSE);
|
||||
_app_icons_loadfromfile (
|
||||
path,
|
||||
0,
|
||||
&icon_info.uwp_icon_id,
|
||||
&icon_info.uwp_hicon,
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
|
||||
_r_obj_dereference (path);
|
||||
@@ -142,7 +160,13 @@ HICON _app_icons_getsafeapp_hicon (
|
||||
return hicon;
|
||||
}
|
||||
|
||||
_app_icons_loadfromfile (ptr_app->real_path, ptr_app->type, &icon_id, &hicon, TRUE);
|
||||
_app_icons_loadfromfile (
|
||||
ptr_app->real_path,
|
||||
ptr_app->type,
|
||||
&icon_id,
|
||||
&hicon,
|
||||
TRUE
|
||||
);
|
||||
|
||||
if (!icon_id ||
|
||||
((ptr_app->type == DATA_APP_UWP || ptr_app->type == DATA_APP_SERVICE) && icon_id == icon_info->app_icon_id))
|
||||
|
||||
+27
-5
@@ -985,14 +985,36 @@ VOID _app_listview_setview (
|
||||
BOOLEAN is_mainview;
|
||||
|
||||
is_mainview = (listview_id >= IDC_APPS_PROFILE) && (listview_id <= IDC_RULES_CUSTOM);
|
||||
view_type = is_mainview ? _r_calc_clamp (_r_config_getlong (L"ViewType", LV_VIEW_DETAILS), LV_VIEW_ICON, LV_VIEW_MAX) : LV_VIEW_DETAILS;
|
||||
icons_size = is_mainview ? _r_calc_clamp (_r_config_getlong (L"IconSize", SHIL_SMALL), SHIL_LARGE, SHIL_LAST) : SHIL_SMALL;
|
||||
|
||||
if (listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM ||
|
||||
if (is_mainview)
|
||||
{
|
||||
view_type = _r_calc_clamp (_r_config_getlong (L"ViewType", LV_VIEW_DETAILS), LV_VIEW_ICON, LV_VIEW_MAX);
|
||||
}
|
||||
else
|
||||
{
|
||||
view_type = LV_VIEW_DETAILS;
|
||||
}
|
||||
|
||||
if (is_mainview)
|
||||
{
|
||||
icons_size = _r_calc_clamp (_r_config_getlong (L"IconSize", SHIL_SMALL), SHIL_LARGE, SHIL_LAST);
|
||||
}
|
||||
else
|
||||
{
|
||||
icons_size = SHIL_SMALL;
|
||||
}
|
||||
|
||||
if ((listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM) ||
|
||||
listview_id == IDC_APP_RULES_ID)
|
||||
{
|
||||
himg = (icons_size == SHIL_SMALL || icons_size == SHIL_SYSSMALL) ?
|
||||
config.himg_rules_small : config.himg_rules_large;
|
||||
if (icons_size == SHIL_SMALL || icons_size == SHIL_SYSSMALL)
|
||||
{
|
||||
himg = config.himg_rules_small;
|
||||
}
|
||||
else
|
||||
{
|
||||
himg = config.himg_rules_large;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+921
-292
File diff suppressed because it is too large.
Load diff
+16
-2
@@ -120,8 +120,22 @@ typedef enum _ENUM_INFO_DATA2
|
||||
#define SZ_DIRECTION_ANY L"Any"
|
||||
#define SZ_DIRECTION_LOOPBACK L"Loopback"
|
||||
|
||||
#define SZ_LOG_TITLE L"Date,Username,Path,Address (" SZ_DIRECTION_LOCAL L"),Port (" SZ_DIRECTION_LOCAL L"),Address (" SZ_DIRECTION_REMOTE L"),Port (" SZ_DIRECTION_REMOTE L"),Protocol,Layer,Filter name,Filter ID,Direction,State\r\n"
|
||||
#define SZ_LOG_BODY L"\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"#%" TEXT (PRIu64) L"\",\"%s\",\"%s\"\r\n"
|
||||
#define SZ_LOG_TITLE L"Date,Username,Path,Address (" SZ_DIRECTION_LOCAL L")," \
|
||||
L"Port (" SZ_DIRECTION_LOCAL L"),Address (" SZ_DIRECTION_REMOTE L"),Port (" SZ_DIRECTION_REMOTE L")," \
|
||||
L"Protocol,Layer,Filter name,Filter ID,Direction,State\r\n"
|
||||
|
||||
#define SZ_LOG_BODY L"\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"," \
|
||||
L"\"%s\",\"%s\",\"#%" TEXT (PRIu64) L"\",\"%s\",\"%s\"\r\n"
|
||||
|
||||
#define SZ_WARNING_ME L"If you disallow this, you cannot use resolve network addresses option. Continue?"
|
||||
#define SZ_WARNING_SVCHOST L"Be careful, through service host (svchost.exe)" \
|
||||
L"internet traffic can let out through unexpected ways. Continue?"
|
||||
|
||||
#define SZ_HELP L"\"simplewall.exe -install\" - enable filtering.\r\n" \
|
||||
L"\"simplewall.exe -install -temp\" - enable filtering until reboot.\r\n" \
|
||||
L"\"simplewall.exe -install -silent\" - enable filtering without prompt.\r\n" \
|
||||
L"\"simplewall.exe -uninstall\" - remove all installed filters.\r\n" \
|
||||
L"\"simplewall.exe -help\" - show this message."
|
||||
|
||||
#define BACKUP_HOURS_PERIOD _r_calc_hours2seconds (4) // make backup every X hour(s) (default)
|
||||
|
||||
|
||||
+947
-211
File diff suppressed because it is too large.
Load diff
+9
-2
@@ -838,8 +838,15 @@ VOID _app_network_printlistviewtable (
|
||||
BOOLEAN is_highlight;
|
||||
BOOLEAN is_refresh;
|
||||
|
||||
is_highlight = _r_config_getboolean (L"IsEnableHighlighting", TRUE) &&
|
||||
_r_config_getboolean_ex (L"IsHighlightConnection", TRUE, L"colors");
|
||||
if (_r_config_getboolean (L"IsEnableHighlighting", TRUE) &&
|
||||
_r_config_getboolean_ex (L"IsHighlightConnection", TRUE, L"colors"))
|
||||
{
|
||||
is_highlight = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_highlight = FALSE;
|
||||
}
|
||||
|
||||
is_refresh = FALSE;
|
||||
|
||||
|
||||
+14
-3
@@ -144,7 +144,13 @@ VOID _app_search_drawbutton (
|
||||
if (!hdc)
|
||||
return;
|
||||
|
||||
SetRect (&rect, 0, 0, button_rect->right - button_rect->left, button_rect->bottom - button_rect->top);
|
||||
SetRect (
|
||||
&rect,
|
||||
0,
|
||||
0,
|
||||
button_rect->right - button_rect->left,
|
||||
button_rect->bottom - button_rect->top
|
||||
);
|
||||
|
||||
buffer_dc = CreateCompatibleDC (hdc);
|
||||
buffer_bitmap = CreateCompatibleBitmap (hdc, rect.right, rect.bottom);
|
||||
@@ -342,7 +348,8 @@ BOOLEAN _app_search_applyfilteritem (
|
||||
goto CleanupExit;
|
||||
}
|
||||
}
|
||||
else if ((listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM) || listview_id == IDC_APP_RULES_ID)
|
||||
else if ((listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM) ||
|
||||
listview_id == IDC_APP_RULES_ID)
|
||||
{
|
||||
ptr_rule = _app_getrulebyid (context->id_code);
|
||||
|
||||
@@ -535,8 +542,12 @@ VOID _app_search_applyfilter (
|
||||
_In_opt_ PR_STRING search_string
|
||||
)
|
||||
{
|
||||
if (!((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_LOG) || listview_id == IDC_RULE_APPS_ID || listview_id == IDC_APP_RULES_ID))
|
||||
if (!((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_LOG) ||
|
||||
listview_id == IDC_RULE_APPS_ID ||
|
||||
listview_id == IDC_APP_RULES_ID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_app_search_applyfiltercallback (hwnd, listview_id, search_string);
|
||||
}
|
||||
|
||||
@@ -2922,9 +2922,15 @@ BOOLEAN _wfp_create2filters (
|
||||
);
|
||||
|
||||
// block inbound connections
|
||||
action = (_r_config_getboolean (L"UseStealthMode", TRUE) ||
|
||||
_r_config_getboolean (L"BlockInboundConnections", TRUE)) ?
|
||||
FWP_ACTION_BLOCK : FWP_ACTION_PERMIT;
|
||||
if (_r_config_getboolean (L"UseStealthMode", TRUE) ||
|
||||
_r_config_getboolean (L"BlockInboundConnections", TRUE))
|
||||
{
|
||||
action = FWP_ACTION_BLOCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
action = FWP_ACTION_PERMIT;
|
||||
}
|
||||
|
||||
_wfp_createfilter (
|
||||
engine_handle,
|
||||
|
||||
Reference in new issue
Block a user