mirror of
https://github.com/henrypp/simplewall.git
synced 2026-10-22 02:52:54 -05:00
code cosmetics
This commit is contained in:
13 files changed
+722
-690
No files matched your search
+25
-25
@@ -44,7 +44,7 @@ BOOLEAN _app_initinterfacestate (HWND hwnd, BOOLEAN is_forced)
|
||||
SendDlgItemMessage (config.hrebar, IDC_TOOLBAR, TB_ENABLEBUTTON, IDM_TRAY_START, MAKELPARAM (FALSE, 0));
|
||||
SendDlgItemMessage (config.hrebar, IDC_TOOLBAR, TB_ENABLEBUTTON, IDM_REFRESH, MAKELPARAM (FALSE, 0));
|
||||
|
||||
_r_status_settext (hwnd, IDC_STATUSBAR, 0, app.LocaleString (IDS_STATUS_FILTERS_PROCESSING, L"..."));
|
||||
_r_status_settext (hwnd, IDC_STATUSBAR, 0, app.LocaleString (IDS_STATUS_FILTERS_PROCESSING, L"...").GetString ());
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ VOID _app_restoreinterfacestate (HWND hwnd, BOOLEAN is_enabled)
|
||||
|
||||
ENUM_INSTALL_TYPE install_type = _wfp_isfiltersinstalled ();
|
||||
|
||||
_r_status_settext (hwnd, IDC_STATUSBAR, 0, app.LocaleString (_app_getinterfacestatelocale (install_type), NULL));
|
||||
_r_status_settext (hwnd, IDC_STATUSBAR, 0, app.LocaleString (_app_getinterfacestatelocale (install_type), NULL).GetString ());
|
||||
}
|
||||
|
||||
VOID _app_setinterfacestate (HWND hwnd)
|
||||
@@ -82,9 +82,9 @@ VOID _app_setinterfacestate (HWND hwnd)
|
||||
//SendDlgItemMessage (hwnd, IDC_STATUSBAR, SB_SETICON, 0, (LPARAM)hico_sm);
|
||||
|
||||
if (!_wfp_isfiltersapplying ())
|
||||
_r_status_settext (hwnd, IDC_STATUSBAR, 0, app.LocaleString (_app_getinterfacestatelocale (install_type), NULL));
|
||||
_r_status_settext (hwnd, IDC_STATUSBAR, 0, app.LocaleString (_app_getinterfacestatelocale (install_type), NULL).GetString ());
|
||||
|
||||
_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_START, app.LocaleString (string_id, NULL), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, is_filtersinstalled ? 1 : 0);
|
||||
_r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_START, app.LocaleString (string_id, NULL).GetString (), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, is_filtersinstalled ? 1 : 0);
|
||||
|
||||
_r_tray_setinfo (hwnd, UID, hico_sm, APP_NAME);
|
||||
}
|
||||
@@ -134,7 +134,7 @@ VOID _app_listviewresize (HWND hwnd, INT listview_id, BOOLEAN is_forced)
|
||||
|
||||
// get column text width
|
||||
rstring column_text = _r_listview_getcolumntext (hwnd, listview_id, i);
|
||||
INT column_width = _r_dc_fontwidth (hdc_header, column_text, column_text.GetLength ()) + spacing;
|
||||
INT column_width = _r_dc_fontwidth (hdc_header, column_text.GetString (), column_text.GetLength ()) + spacing;
|
||||
|
||||
if (column_width >= max_width)
|
||||
{
|
||||
@@ -148,7 +148,7 @@ VOID _app_listviewresize (HWND hwnd, INT listview_id, BOOLEAN is_forced)
|
||||
for (INT j = 0; j < _r_listview_getitemcount (hwnd, listview_id, FALSE); j++)
|
||||
{
|
||||
rstring item_text = _r_listview_getitemtext (hwnd, listview_id, j, i);
|
||||
INT text_width = _r_dc_fontwidth (hdc_listview, item_text, item_text.GetLength ()) + spacing;
|
||||
INT text_width = _r_dc_fontwidth (hdc_listview, item_text.GetString (), item_text.GetLength ()) + spacing;
|
||||
|
||||
// do not continue reaching higher and higher values for performance reason!
|
||||
if (text_width >= max_width)
|
||||
@@ -196,7 +196,7 @@ VOID _app_listviewsetview (HWND hwnd, INT listview_id)
|
||||
}
|
||||
else
|
||||
{
|
||||
SHGetImageList (icons_size, IID_IImageList2, (LPVOID*)&himg);
|
||||
SHGetImageList (icons_size, IID_IImageList2, (PVOID*)&himg);
|
||||
}
|
||||
|
||||
if (himg)
|
||||
@@ -216,18 +216,18 @@ VOID _app_listviewinitfont (HWND hwnd, PLOGFONT plf)
|
||||
if (!buffer.IsEmpty ())
|
||||
{
|
||||
rstringvec rvc;
|
||||
_r_str_split (buffer, buffer.GetLength (), L';', rvc);
|
||||
_r_str_split (buffer.GetString (), buffer.GetLength (), L';', rvc);
|
||||
|
||||
if (!rvc.empty ())
|
||||
{
|
||||
_r_str_copy (plf->lfFaceName, LF_FACESIZE, rvc.at (0)); // face name
|
||||
_r_str_copy (plf->lfFaceName, LF_FACESIZE, rvc.at (0).GetString ()); // face name
|
||||
|
||||
if (rvc.size () >= 2)
|
||||
{
|
||||
plf->lfHeight = _r_dc_fontsizetoheight (hwnd, _r_str_tointeger (rvc.at (1))); // size
|
||||
plf->lfHeight = _r_dc_fontsizetoheight (hwnd, _r_str_tointeger (rvc.at (1).GetString ())); // size
|
||||
|
||||
if (rvc.size () >= 3)
|
||||
plf->lfWeight = _r_str_tointeger (rvc.at (2)); // weight
|
||||
plf->lfWeight = _r_str_tointeger (rvc.at (2).GetString ()); // weight
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,8 +288,8 @@ INT CALLBACK _app_listviewcompare_callback (LPARAM lparam1, LPARAM lparam2, LPAR
|
||||
|
||||
rstring cfg_name = _r_fmt (L"listview\\%04" TEXT (PRIX32), listview_id);
|
||||
|
||||
INT column_id = app.ConfigGetInteger (L"SortColumn", 0, cfg_name);
|
||||
BOOLEAN is_descend = app.ConfigGetBoolean (L"SortIsDescending", FALSE, cfg_name);
|
||||
INT column_id = app.ConfigGetInteger (L"SortColumn", 0, cfg_name.GetString ());
|
||||
BOOLEAN is_descend = app.ConfigGetBoolean (L"SortIsDescending", FALSE, cfg_name.GetString ());
|
||||
|
||||
INT result = 0;
|
||||
|
||||
@@ -330,8 +330,8 @@ INT CALLBACK _app_listviewcompare_callback (LPARAM lparam1, LPARAM lparam2, LPAR
|
||||
if (!result)
|
||||
{
|
||||
result = _r_str_compare_logical (
|
||||
_r_listview_getitemtext (hparent, listview_id, item1, column_id),
|
||||
_r_listview_getitemtext (hparent, listview_id, item2, column_id)
|
||||
_r_listview_getitemtext (hparent, listview_id, item1, column_id).GetString (),
|
||||
_r_listview_getitemtext (hparent, listview_id, item2, column_id).GetString ()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -354,20 +354,20 @@ VOID _app_listviewsort (HWND hwnd, INT listview_id, INT column_id, BOOLEAN is_no
|
||||
return;
|
||||
|
||||
rstring cfg_name = _r_fmt (L"listview\\%04" TEXT (PRIX32), listview_id);
|
||||
BOOLEAN is_descend = app.ConfigGetBoolean (L"SortIsDescending", FALSE, cfg_name);
|
||||
BOOLEAN is_descend = app.ConfigGetBoolean (L"SortIsDescending", FALSE, cfg_name.GetString ());
|
||||
|
||||
if (is_notifycode)
|
||||
is_descend = !is_descend;
|
||||
|
||||
if (column_id == INVALID_INT)
|
||||
column_id = app.ConfigGetInteger (L"SortColumn", 0, cfg_name);
|
||||
column_id = app.ConfigGetInteger (L"SortColumn", 0, cfg_name.GetString ());
|
||||
|
||||
column_id = _r_calc_clamp (INT, column_id, 0, column_count - 1); // set range
|
||||
|
||||
if (is_notifycode)
|
||||
{
|
||||
app.ConfigSetBoolean (L"SortIsDescending", is_descend, cfg_name);
|
||||
app.ConfigSetInteger (L"SortColumn", column_id, cfg_name);
|
||||
app.ConfigSetBoolean (L"SortIsDescending", is_descend, cfg_name.GetString ());
|
||||
app.ConfigSetInteger (L"SortColumn", column_id, cfg_name.GetString ());
|
||||
}
|
||||
|
||||
for (INT i = 0; i < column_count; i++)
|
||||
@@ -446,9 +446,9 @@ VOID _app_refreshgroups (HWND hwnd, INT listview_id)
|
||||
}
|
||||
}
|
||||
|
||||
_r_listview_setgroup (hwnd, listview_id, 0, app.LocaleString (group1_title, total_count ? _r_fmt (L" (%d/%d)", group1_count, total_count).GetString () : NULL), 0, 0);
|
||||
_r_listview_setgroup (hwnd, listview_id, 1, app.LocaleString (group2_title, total_count ? _r_fmt (L" (%d/%d)", group2_count, total_count).GetString () : NULL), 0, 0);
|
||||
_r_listview_setgroup (hwnd, listview_id, 2, app.LocaleString (group3_title, total_count ? _r_fmt (L" (%d/%d)", group3_count, total_count).GetString () : NULL), 0, 0);
|
||||
_r_listview_setgroup (hwnd, listview_id, 0, app.LocaleString (group1_title, total_count ? _r_fmt (L" (%d/%d)", group1_count, total_count).GetString () : NULL).GetString (), 0, 0);
|
||||
_r_listview_setgroup (hwnd, listview_id, 1, app.LocaleString (group2_title, total_count ? _r_fmt (L" (%d/%d)", group2_count, total_count).GetString () : NULL).GetString (), 0, 0);
|
||||
_r_listview_setgroup (hwnd, listview_id, 2, app.LocaleString (group3_title, total_count ? _r_fmt (L" (%d/%d)", group3_count, total_count).GetString () : NULL).GetString (), 0, 0);
|
||||
}
|
||||
|
||||
VOID _app_refreshstatus (HWND hwnd, INT listview_id)
|
||||
@@ -495,7 +495,7 @@ VOID _app_refreshstatus (HWND hwnd, INT listview_id)
|
||||
|
||||
if (i)
|
||||
{
|
||||
size[i] = _r_dc_fontwidth (hdc, text[i], text[i].GetLength ()) + spacing;
|
||||
size[i] = _r_dc_fontwidth (hdc, text[i].GetString (), text[i].GetLength ()) + spacing;
|
||||
lay += size[i];
|
||||
}
|
||||
}
|
||||
@@ -510,7 +510,7 @@ VOID _app_refreshstatus (HWND hwnd, INT listview_id)
|
||||
SendMessage (hstatus, SB_SETPARTS, parts_count, (LPARAM)parts);
|
||||
|
||||
for (INT i = 1; i < parts_count; i++)
|
||||
_r_status_settext (hwnd, IDC_STATUSBAR, i, text[i]);
|
||||
_r_status_settext (hwnd, IDC_STATUSBAR, i, text[i].GetString ());
|
||||
|
||||
ReleaseDC (hstatus, hdc);
|
||||
}
|
||||
@@ -583,7 +583,7 @@ LONG_PTR _app_nmcustdraw_listview (LPNMLVCUSTOMDRAW lpnmlv)
|
||||
INT view_type = (INT)SendMessage (lpnmlv->nmcd.hdr.hwndFrom, LVM_GETVIEW, 0, 0);
|
||||
BOOLEAN is_tableview = (view_type == LV_VIEW_DETAILS || view_type == LV_VIEW_SMALLICON || view_type == LV_VIEW_TILE);
|
||||
|
||||
INT listview_id = PtrToInt ((LPVOID)lpnmlv->nmcd.hdr.idFrom);
|
||||
INT listview_id = PtrToInt ((PVOID)lpnmlv->nmcd.hdr.idFrom);
|
||||
|
||||
if ((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP) || listview_id == IDC_RULE_APPS_ID || listview_id == IDC_NETWORK || listview_id == IDC_LOG)
|
||||
{
|
||||
|
||||
+58
-58
@@ -20,15 +20,15 @@ INT_PTR CALLBACK AddRuleProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
_r_wnd_center (hwnd, GetParent (hwnd));
|
||||
|
||||
// localize window
|
||||
SetWindowText (hwnd, app.LocaleString (IDS_RULE, NULL));
|
||||
SetWindowText (hwnd, app.LocaleString (IDS_RULE, NULL).GetString ());
|
||||
|
||||
if (pcontext->item_id != INVALID_INT)
|
||||
SetDlgItemText (hwnd, IDC_RULE_ID, _r_listview_getitemtext (pcontext->hwnd, pcontext->listview_id, pcontext->item_id, 0));
|
||||
SetDlgItemText (hwnd, IDC_RULE_ID, _r_listview_getitemtext (pcontext->hwnd, pcontext->listview_id, pcontext->item_id, 0).GetString ());
|
||||
|
||||
SetDlgItemText (hwnd, IDC_RULE_HINT, L"eg. 192.168.0.1\r\neg. [fe80::]\r\neg. 192.168.0.1:443\r\neg. [fe80::]:443\r\neg. 192.168.0.1-192.168.0.255\r\neg. 192.168.0.1-192.168.0.255:443\r\neg. 192.168.0.0/16\r\neg. fe80::/10\r\neg. 80\r\neg. 443\r\neg. 20-21\r\neg. 49152-65534");
|
||||
|
||||
SetDlgItemText (hwnd, IDC_SAVE, app.LocaleString (pcontext->item_id != INVALID_INT ? IDS_SAVE : IDS_ADD, NULL));
|
||||
SetDlgItemText (hwnd, IDC_CLOSE, app.LocaleString (IDS_CLOSE, NULL));
|
||||
SetDlgItemText (hwnd, IDC_SAVE, app.LocaleString (pcontext->item_id != INVALID_INT ? IDS_SAVE : IDS_ADD, NULL).GetString ());
|
||||
SetDlgItemText (hwnd, IDC_CLOSE, app.LocaleString (IDS_CLOSE, NULL).GetString ());
|
||||
|
||||
_r_wnd_addstyle (hwnd, IDC_SAVE, app.IsClassicUI () ? WS_EX_STATICEDGE : 0, WS_EX_STATICEDGE, GWL_EXSTYLE);
|
||||
_r_wnd_addstyle (hwnd, IDC_CLOSE, app.IsClassicUI () ? WS_EX_STATICEDGE : 0, WS_EX_STATICEDGE, GWL_EXSTYLE);
|
||||
@@ -83,7 +83,7 @@ INT_PTR CALLBACK AddRuleProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
|
||||
if (!_app_parserulestring (rule_single, NULL))
|
||||
{
|
||||
_r_ctrl_showtip (hwnd, IDC_RULE_ID, 0, NULL, app.LocaleString (IDS_STATUS_SYNTAX_ERROR, NULL));
|
||||
_r_ctrl_showtip (hwnd, IDC_RULE_ID, 0, NULL, app.LocaleString (IDS_STATUS_SYNTAX_ERROR, NULL).GetString ());
|
||||
_r_ctrl_enable (hwnd, IDC_SAVE, FALSE);
|
||||
|
||||
return FALSE;
|
||||
@@ -91,11 +91,11 @@ INT_PTR CALLBACK AddRuleProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
|
||||
if (pcontext->item_id == INVALID_INT)
|
||||
{
|
||||
_r_listview_additem (pcontext->hwnd, pcontext->listview_id, INVALID_INT, 0, rule_single);
|
||||
_r_listview_additem (pcontext->hwnd, pcontext->listview_id, INVALID_INT, 0, rule_single.GetString ());
|
||||
}
|
||||
else
|
||||
{
|
||||
_r_listview_setitem (pcontext->hwnd, pcontext->listview_id, pcontext->item_id, 0, rule_single);
|
||||
_r_listview_setitem (pcontext->hwnd, pcontext->listview_id, pcontext->item_id, 0, rule_single.GetString ());
|
||||
}
|
||||
|
||||
[[fallthrough]];
|
||||
@@ -137,7 +137,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
// name
|
||||
if (GetDlgItem (hwnd, IDC_RULE_NAME_ID))
|
||||
{
|
||||
SetDlgItemText (hwnd, IDC_RULE_NAME, app.LocaleString (IDS_NAME, L":"));
|
||||
SetDlgItemText (hwnd, IDC_RULE_NAME, app.LocaleString (IDS_NAME, L":").GetString ());
|
||||
|
||||
if (!_r_str_isempty (ptr_rule->pname))
|
||||
SetDlgItemText (hwnd, IDC_RULE_NAME_ID, ptr_rule->pname);
|
||||
@@ -151,11 +151,11 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
// direction
|
||||
if (GetDlgItem (hwnd, IDC_RULE_DIRECTION))
|
||||
{
|
||||
SetDlgItemText (hwnd, IDC_RULE_DIRECTION, app.LocaleString (IDS_DIRECTION, L":"));
|
||||
SetDlgItemText (hwnd, IDC_RULE_DIRECTION, app.LocaleString (IDS_DIRECTION, L":").GetString ());
|
||||
|
||||
SetDlgItemText (hwnd, IDC_RULE_DIRECTION_OUTBOUND, app.LocaleString (IDS_DIRECTION_1, NULL));
|
||||
SetDlgItemText (hwnd, IDC_RULE_DIRECTION_INBOUND, app.LocaleString (IDS_DIRECTION_2, NULL));
|
||||
SetDlgItemText (hwnd, IDC_RULE_DIRECTION_ANY, text_any);
|
||||
SetDlgItemText (hwnd, IDC_RULE_DIRECTION_OUTBOUND, app.LocaleString (IDS_DIRECTION_1, NULL).GetString ());
|
||||
SetDlgItemText (hwnd, IDC_RULE_DIRECTION_INBOUND, app.LocaleString (IDS_DIRECTION_2, NULL).GetString ());
|
||||
SetDlgItemText (hwnd, IDC_RULE_DIRECTION_ANY, text_any.GetString ());
|
||||
|
||||
if (ptr_rule->direction == FWP_DIRECTION_OUTBOUND)
|
||||
CheckRadioButton (hwnd, IDC_RULE_DIRECTION_OUTBOUND, IDC_RULE_DIRECTION_ANY, IDC_RULE_DIRECTION_OUTBOUND);
|
||||
@@ -174,10 +174,10 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
// action
|
||||
if (GetDlgItem (hwnd, IDC_RULE_ACTION))
|
||||
{
|
||||
SetDlgItemText (hwnd, IDC_RULE_ACTION, app.LocaleString (IDS_ACTION, L":"));
|
||||
SetDlgItemText (hwnd, IDC_RULE_ACTION, app.LocaleString (IDS_ACTION, L":").GetString ());
|
||||
|
||||
SetDlgItemText (hwnd, IDC_RULE_ACTION_BLOCK, app.LocaleString (IDS_ACTION_BLOCK, NULL));
|
||||
SetDlgItemText (hwnd, IDC_RULE_ACTION_ALLOW, app.LocaleString (IDS_ACTION_ALLOW, NULL));
|
||||
SetDlgItemText (hwnd, IDC_RULE_ACTION_BLOCK, app.LocaleString (IDS_ACTION_BLOCK, NULL).GetString ());
|
||||
SetDlgItemText (hwnd, IDC_RULE_ACTION_ALLOW, app.LocaleString (IDS_ACTION_ALLOW, NULL).GetString ());
|
||||
|
||||
CheckRadioButton (hwnd, IDC_RULE_ACTION_BLOCK, IDC_RULE_ACTION_ALLOW, ptr_rule->is_block ? IDC_RULE_ACTION_BLOCK : IDC_RULE_ACTION_ALLOW);
|
||||
|
||||
@@ -188,7 +188,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
// protocols
|
||||
if (GetDlgItem (hwnd, IDC_RULE_PROTOCOL_ID))
|
||||
{
|
||||
SetDlgItemText (hwnd, IDC_RULE_PROTOCOL, app.LocaleString (IDS_PROTOCOL, L":"));
|
||||
SetDlgItemText (hwnd, IDC_RULE_PROTOCOL, app.LocaleString (IDS_PROTOCOL, L":").GetString ());
|
||||
|
||||
UINT8 protos[] = {
|
||||
IPPROTO_ICMP,
|
||||
@@ -215,7 +215,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
|
||||
for (auto &proto : protos)
|
||||
{
|
||||
SendDlgItemMessage (hwnd, IDC_RULE_PROTOCOL_ID, CB_INSERTSTRING, (WPARAM)index, (LPARAM)_r_fmt (L"%s (%" TEXT (PRIu8) L")", _app_getprotoname (proto, AF_UNSPEC).GetString (), proto).GetString ());
|
||||
SendDlgItemMessage (hwnd, IDC_RULE_PROTOCOL_ID, CB_INSERTSTRING, (WPARAM)index, (LPARAM)_r_fmt (L"%s (%" TEXT (PRIu8) L")", _app_getprotoname (proto, AF_UNSPEC, SZ_UNKNOWN).GetString (), proto).GetString ());
|
||||
SendDlgItemMessage (hwnd, IDC_RULE_PROTOCOL_ID, CB_SETITEMDATA, (WPARAM)index, (LPARAM)proto);
|
||||
|
||||
if (ptr_rule->protocol == proto)
|
||||
@@ -227,7 +227,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
// unknown protocol
|
||||
if (SendDlgItemMessage (hwnd, IDC_RULE_PROTOCOL_ID, CB_GETCURSEL, 0, 0) == CB_ERR)
|
||||
{
|
||||
SendDlgItemMessage (hwnd, IDC_RULE_PROTOCOL_ID, CB_INSERTSTRING, (WPARAM)index, (LPARAM)_r_fmt (L"%s (%" TEXT (PRIu8) L")", _app_getprotoname (ptr_rule->protocol, AF_UNSPEC).GetString (), ptr_rule->protocol).GetString ());
|
||||
SendDlgItemMessage (hwnd, IDC_RULE_PROTOCOL_ID, CB_INSERTSTRING, (WPARAM)index, (LPARAM)_r_fmt (L"%s (%" TEXT (PRIu8) L")", _app_getprotoname (ptr_rule->protocol, AF_UNSPEC, SZ_UNKNOWN).GetString (), ptr_rule->protocol).GetString ());
|
||||
SendDlgItemMessage (hwnd, IDC_RULE_PROTOCOL_ID, CB_SETITEMDATA, (WPARAM)index, (LPARAM)ptr_rule->protocol);
|
||||
|
||||
SendDlgItemMessage (hwnd, IDC_RULE_PROTOCOL_ID, CB_SETCURSEL, (WPARAM)index, 0);
|
||||
@@ -239,7 +239,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
// rule (remote)
|
||||
if (GetDlgItem (hwnd, IDC_RULE_REMOTE_ID))
|
||||
{
|
||||
SetDlgItemText (hwnd, IDC_RULE_REMOTE, app.LocaleString (IDS_RULE, L" (" SZ_DIRECTION_REMOTE L"):"));
|
||||
SetDlgItemText (hwnd, IDC_RULE_REMOTE, app.LocaleString (IDS_RULE, L" (" SZ_DIRECTION_REMOTE L"):").GetString ());
|
||||
|
||||
_r_listview_setstyle (hwnd, IDC_RULE_REMOTE_ID, LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP, FALSE);
|
||||
_r_listview_addcolumn (hwnd, IDC_RULE_REMOTE_ID, 0, NULL, -100, 0);
|
||||
@@ -256,7 +256,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
_r_str_trim (rule_single, DIVIDER_TRIM DIVIDER_RULE);
|
||||
|
||||
_r_fastlock_acquireshared (&lock_checkbox);
|
||||
_r_listview_additem (hwnd, IDC_RULE_REMOTE_ID, index, 0, rule_single);
|
||||
_r_listview_additem (hwnd, IDC_RULE_REMOTE_ID, index, 0, rule_single.GetString ());
|
||||
_r_fastlock_releaseshared (&lock_checkbox);
|
||||
|
||||
index += 1;
|
||||
@@ -265,9 +265,9 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
_r_listview_setcolumn (hwnd, IDC_RULE_REMOTE_ID, 0, NULL, -100);
|
||||
}
|
||||
|
||||
SetDlgItemText (hwnd, IDC_RULE_REMOTE_ADD, app.LocaleString (IDS_ADD, L"..."));
|
||||
SetDlgItemText (hwnd, IDC_RULE_REMOTE_EDIT, app.LocaleString (IDS_EDIT2, L"..."));
|
||||
SetDlgItemText (hwnd, IDC_RULE_REMOTE_DELETE, app.LocaleString (IDS_DELETE, NULL));
|
||||
SetDlgItemText (hwnd, IDC_RULE_REMOTE_ADD, app.LocaleString (IDS_ADD, L"...").GetString ());
|
||||
SetDlgItemText (hwnd, IDC_RULE_REMOTE_EDIT, app.LocaleString (IDS_EDIT2, L"...").GetString ());
|
||||
SetDlgItemText (hwnd, IDC_RULE_REMOTE_DELETE, app.LocaleString (IDS_DELETE, NULL).GetString ());
|
||||
|
||||
_r_ctrl_enable (hwnd, IDC_RULE_REMOTE_ADD, !ptr_rule->is_readonly);
|
||||
_r_ctrl_enable (hwnd, IDC_RULE_REMOTE_EDIT, FALSE);
|
||||
@@ -281,7 +281,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
// rule (local)
|
||||
if (GetDlgItem (hwnd, IDC_RULE_LOCAL_ID))
|
||||
{
|
||||
SetDlgItemText (hwnd, IDC_RULE_LOCAL, app.LocaleString (IDS_RULE, L" (" SZ_DIRECTION_LOCAL L"):"));
|
||||
SetDlgItemText (hwnd, IDC_RULE_LOCAL, app.LocaleString (IDS_RULE, L" (" SZ_DIRECTION_LOCAL L"):").GetString ());
|
||||
|
||||
_r_listview_setstyle (hwnd, IDC_RULE_LOCAL_ID, LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP, FALSE);
|
||||
_r_listview_addcolumn (hwnd, IDC_RULE_LOCAL_ID, 0, NULL, -100, 0);
|
||||
@@ -298,7 +298,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
_r_str_trim (rule_single, DIVIDER_TRIM DIVIDER_RULE);
|
||||
|
||||
_r_fastlock_acquireshared (&lock_checkbox);
|
||||
_r_listview_additem (hwnd, IDC_RULE_LOCAL_ID, index, 0, rule_single);
|
||||
_r_listview_additem (hwnd, IDC_RULE_LOCAL_ID, index, 0, rule_single.GetString ());
|
||||
_r_fastlock_releaseshared (&lock_checkbox);
|
||||
|
||||
index += 1;
|
||||
@@ -307,9 +307,9 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
_r_listview_setcolumn (hwnd, IDC_RULE_LOCAL_ID, 0, NULL, -100);
|
||||
}
|
||||
|
||||
SetDlgItemText (hwnd, IDC_RULE_LOCAL_ADD, app.LocaleString (IDS_ADD, L"..."));
|
||||
SetDlgItemText (hwnd, IDC_RULE_LOCAL_EDIT, app.LocaleString (IDS_EDIT2, L"..."));
|
||||
SetDlgItemText (hwnd, IDC_RULE_LOCAL_DELETE, app.LocaleString (IDS_DELETE, NULL));
|
||||
SetDlgItemText (hwnd, IDC_RULE_LOCAL_ADD, app.LocaleString (IDS_ADD, L"...").GetString ());
|
||||
SetDlgItemText (hwnd, IDC_RULE_LOCAL_EDIT, app.LocaleString (IDS_EDIT2, L"...").GetString ());
|
||||
SetDlgItemText (hwnd, IDC_RULE_LOCAL_DELETE, app.LocaleString (IDS_DELETE, NULL).GetString ());
|
||||
|
||||
_r_ctrl_enable (hwnd, IDC_RULE_LOCAL_ADD, !ptr_rule->is_readonly);
|
||||
_r_ctrl_enable (hwnd, IDC_RULE_LOCAL_EDIT, FALSE);
|
||||
@@ -327,7 +327,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
|
||||
_r_listview_setstyle (hwnd, IDC_RULE_APPS_ID, LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP | LVS_EX_CHECKBOXES, TRUE);
|
||||
|
||||
_r_listview_addcolumn (hwnd, IDC_RULE_APPS_ID, 0, app.LocaleString (IDS_NAME, NULL), 0, LVCFMT_LEFT);
|
||||
_r_listview_addcolumn (hwnd, IDC_RULE_APPS_ID, 0, app.LocaleString (IDS_NAME, NULL).GetString (), 0, LVCFMT_LEFT);
|
||||
|
||||
_r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 0, L"", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);
|
||||
_r_listview_addgroup (hwnd, IDC_RULE_APPS_ID, 1, L"", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);
|
||||
@@ -382,10 +382,10 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
|
||||
// hints
|
||||
if (GetDlgItem (hwnd, IDC_RULE_HINT))
|
||||
SetDlgItemText (hwnd, IDC_RULE_HINT, app.LocaleString (IDS_RULE_HINT, NULL));
|
||||
SetDlgItemText (hwnd, IDC_RULE_HINT, app.LocaleString (IDS_RULE_HINT, NULL).GetString ());
|
||||
|
||||
if (GetDlgItem (hwnd, IDC_RULE_APPS_HINT))
|
||||
SetDlgItemText (hwnd, IDC_RULE_APPS_HINT, app.LocaleString (IDS_RULE_APPS_HINT, NULL));
|
||||
SetDlgItemText (hwnd, IDC_RULE_APPS_HINT, app.LocaleString (IDS_RULE_APPS_HINT, NULL).GetString ());
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -412,7 +412,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
break;
|
||||
|
||||
INT command_id = 0;
|
||||
INT ctrl_id = PtrToInt ((LPVOID)lpnmlv->hdr.idFrom);
|
||||
INT ctrl_id = PtrToInt ((PVOID)lpnmlv->hdr.idFrom);
|
||||
|
||||
if (ctrl_id == IDC_RULE_REMOTE_ID)
|
||||
{
|
||||
@@ -433,7 +433,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
{
|
||||
LPNMITEMACTIVATE lpnmlv = (LPNMITEMACTIVATE)lparam;
|
||||
|
||||
INT listview_id = PtrToInt ((LPVOID)lpnmlv->hdr.idFrom);
|
||||
INT listview_id = PtrToInt ((PVOID)lpnmlv->hdr.idFrom);
|
||||
|
||||
if (
|
||||
listview_id != IDC_RULE_REMOTE_ID &&
|
||||
@@ -459,11 +459,11 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
UINT id_edit = is_remote ? IDC_RULE_REMOTE_EDIT : IDC_RULE_LOCAL_EDIT;
|
||||
UINT id_delete = is_remote ? IDC_RULE_REMOTE_DELETE : IDC_RULE_LOCAL_DELETE;
|
||||
|
||||
AppendMenu (hsubmenu, MF_STRING, id_add, app.LocaleString (IDS_ADD, L"..."));
|
||||
AppendMenu (hsubmenu, MF_STRING, id_edit, app.LocaleString (IDS_EDIT2, L"..."));
|
||||
AppendMenu (hsubmenu, MF_STRING, id_delete, app.LocaleString (IDS_DELETE, NULL));
|
||||
AppendMenu (hsubmenu, MF_STRING, id_add, app.LocaleString (IDS_ADD, L"...").GetString ());
|
||||
AppendMenu (hsubmenu, MF_STRING, id_edit, app.LocaleString (IDS_EDIT2, L"...").GetString ());
|
||||
AppendMenu (hsubmenu, MF_STRING, id_delete, app.LocaleString (IDS_DELETE, NULL).GetString ());
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, NULL));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, NULL).GetString ());
|
||||
|
||||
if (ptr_rule->is_readonly)
|
||||
{
|
||||
@@ -481,12 +481,12 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
}
|
||||
else if (listview_id == IDC_RULE_APPS_ID)
|
||||
{
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_CHECK, app.LocaleString (IDS_CHECK, NULL));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_UNCHECK, app.LocaleString (IDS_UNCHECK, NULL));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_CHECK, app.LocaleString (IDS_CHECK, NULL).GetString ());
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_UNCHECK, app.LocaleString (IDS_UNCHECK, NULL).GetString ());
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_PROPERTIES, app.LocaleString (IDS_SHOWINLIST, NULL));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_PROPERTIES, app.LocaleString (IDS_SHOWINLIST, NULL).GetString ());
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, NULL));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, NULL).GetString ());
|
||||
|
||||
if (ptr_rule->type != DataRuleCustom)
|
||||
{
|
||||
@@ -514,7 +514,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
{
|
||||
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lparam;
|
||||
|
||||
INT listview_id = PtrToInt ((LPVOID)lpnmlv->hdr.idFrom);
|
||||
INT listview_id = PtrToInt ((PVOID)lpnmlv->hdr.idFrom);
|
||||
|
||||
_app_listviewsort (hwnd, listview_id, lpnmlv->iSubItem, TRUE);
|
||||
|
||||
@@ -525,7 +525,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
{
|
||||
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lparam;
|
||||
|
||||
INT listview_id = PtrToInt ((LPVOID)lpnmlv->hdr.idFrom);
|
||||
INT listview_id = PtrToInt ((PVOID)lpnmlv->hdr.idFrom);
|
||||
|
||||
if ((lpnmlv->uChanged & LVIF_STATE) != 0)
|
||||
{
|
||||
@@ -549,7 +549,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
{
|
||||
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lparam;
|
||||
|
||||
INT listview_id = PtrToInt ((LPVOID)lpnmlv->hdr.idFrom);
|
||||
INT listview_id = PtrToInt ((PVOID)lpnmlv->hdr.idFrom);
|
||||
|
||||
if ((lpnmlv->uChanged & LVIF_STATE) != 0)
|
||||
{
|
||||
@@ -594,7 +594,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
{
|
||||
LPNMLVGETINFOTIP lpnmlv = (LPNMLVGETINFOTIP)lparam;
|
||||
|
||||
_r_str_copy (lpnmlv->pszText, lpnmlv->cchTextMax, _app_gettooltip (hwnd, lpnmlv));
|
||||
_r_str_copy (lpnmlv->pszText, lpnmlv->cchTextMax, _app_gettooltip (hwnd, lpnmlv).GetString ());
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -604,7 +604,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
NMLVEMPTYMARKUP* lpnmlv = (NMLVEMPTYMARKUP*)lparam;
|
||||
|
||||
lpnmlv->dwFlags = EMF_CENTERED;
|
||||
_r_str_copy (lpnmlv->szMarkup, RTL_NUMBER_OF (lpnmlv->szMarkup), app.LocaleString (IDS_STATUS_EMPTY, NULL));
|
||||
_r_str_copy (lpnmlv->szMarkup, RTL_NUMBER_OF (lpnmlv->szMarkup), app.LocaleString (IDS_STATUS_EMPTY, NULL).GetString ());
|
||||
|
||||
SetWindowLongPtr (hwnd, DWLP_MSGRESULT, TRUE);
|
||||
return TRUE;
|
||||
@@ -664,7 +664,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
INT listview_id = ((ctrl_id == IDC_RULE_REMOTE_DELETE) ? IDC_RULE_REMOTE_ID : IDC_RULE_LOCAL_ID);
|
||||
INT selected = (INT)SendDlgItemMessage (hwnd, listview_id, LVM_GETSELECTEDCOUNT, 0, 0);
|
||||
|
||||
if (!selected || app.ShowMessage (hwnd, MB_YESNO | MB_ICONEXCLAMATION, NULL, NULL, _r_fmt (app.LocaleString (IDS_QUESTION_DELETE, NULL), selected)) != IDYES)
|
||||
if (!selected || app.ShowMessage (hwnd, MB_YESNO | MB_ICONEXCLAMATION, NULL, NULL, _r_fmt (app.LocaleString (IDS_QUESTION_DELETE, NULL).GetString (), selected).GetString ()) != IDYES)
|
||||
break;
|
||||
|
||||
INT count = _r_listview_getitemcount (hwnd, listview_id, FALSE) - 1;
|
||||
@@ -736,7 +736,7 @@ INT_PTR CALLBACK EditorPagesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
|
||||
_r_str_trim (buffer, DIVIDER_TRIM);
|
||||
|
||||
_r_clipboard_set (hwnd, buffer, buffer.GetLength ());
|
||||
_r_clipboard_set (hwnd, buffer.GetString (), buffer.GetLength ());
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -778,9 +778,9 @@ INT_PTR CALLBACK EditorProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
_r_wnd_center (hwnd, GetParent (hwnd));
|
||||
|
||||
//// configure tabs
|
||||
_r_tab_additem (hwnd, IDC_TAB, 0, app.LocaleString (IDS_SETTINGS_GENERAL, NULL), I_IMAGENONE, (LPARAM)CreateDialogParam (app.GetHINSTANCE (), MAKEINTRESOURCE (IDD_EDITOR_GENERAL), hwnd, &EditorPagesProc, (LPARAM)ptr_rule));
|
||||
_r_tab_additem (hwnd, IDC_TAB, 1, app.LocaleString (IDS_RULE, NULL), I_IMAGENONE, (LPARAM)CreateDialogParam (app.GetHINSTANCE (), MAKEINTRESOURCE (IDD_EDITOR_RULE), hwnd, &EditorPagesProc, (LPARAM)ptr_rule));
|
||||
_r_tab_additem (hwnd, IDC_TAB, 2, app.LocaleString (IDS_TAB_APPS, NULL), I_IMAGENONE, (LPARAM)CreateDialogParam (app.GetHINSTANCE (), MAKEINTRESOURCE (IDD_EDITOR_APPS), hwnd, &EditorPagesProc, (LPARAM)ptr_rule));
|
||||
_r_tab_additem (hwnd, IDC_TAB, 0, app.LocaleString (IDS_SETTINGS_GENERAL, NULL).GetString (), I_IMAGENONE, (LPARAM)CreateDialogParam (app.GetHINSTANCE (), MAKEINTRESOURCE (IDD_EDITOR_GENERAL), hwnd, &EditorPagesProc, (LPARAM)ptr_rule));
|
||||
_r_tab_additem (hwnd, IDC_TAB, 1, app.LocaleString (IDS_RULE, NULL).GetString (), I_IMAGENONE, (LPARAM)CreateDialogParam (app.GetHINSTANCE (), MAKEINTRESOURCE (IDD_EDITOR_RULE), hwnd, &EditorPagesProc, (LPARAM)ptr_rule));
|
||||
_r_tab_additem (hwnd, IDC_TAB, 2, app.LocaleString (IDS_TAB_APPS, NULL).GetString (), I_IMAGENONE, (LPARAM)CreateDialogParam (app.GetHINSTANCE (), MAKEINTRESOURCE (IDD_EDITOR_APPS), hwnd, &EditorPagesProc, (LPARAM)ptr_rule));
|
||||
|
||||
#if !defined(_APP_NO_DARKTHEME)
|
||||
_r_wnd_setdarktheme (hwnd);
|
||||
@@ -796,13 +796,13 @@ INT_PTR CALLBACK EditorProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
if (ptr_rule->is_readonly)
|
||||
title.AppendFormat (L" (%s)", SZ_RULE_INTERNAL_TITLE);
|
||||
|
||||
SetWindowText (hwnd, title);
|
||||
SetWindowText (hwnd, title.GetString ());
|
||||
}
|
||||
|
||||
SetDlgItemText (hwnd, IDC_ENABLE_CHK, app.LocaleString (IDS_ENABLE_CHK, NULL));
|
||||
SetDlgItemText (hwnd, IDC_ENABLE_CHK, app.LocaleString (IDS_ENABLE_CHK, NULL).GetString ());
|
||||
|
||||
SetDlgItemText (hwnd, IDC_SAVE, app.LocaleString (IDS_SAVE, NULL));
|
||||
SetDlgItemText (hwnd, IDC_CLOSE, app.LocaleString (IDS_CLOSE, NULL));
|
||||
SetDlgItemText (hwnd, IDC_SAVE, app.LocaleString (IDS_SAVE, NULL).GetString ());
|
||||
SetDlgItemText (hwnd, IDC_CLOSE, app.LocaleString (IDS_CLOSE, NULL).GetString ());
|
||||
|
||||
_r_wnd_addstyle (hwnd, IDC_SAVE, app.IsClassicUI () ? WS_EX_STATICEDGE : 0, WS_EX_STATICEDGE, GWL_EXSTYLE);
|
||||
_r_wnd_addstyle (hwnd, IDC_CLOSE, app.IsClassicUI () ? WS_EX_STATICEDGE : 0, WS_EX_STATICEDGE, GWL_EXSTYLE);
|
||||
@@ -893,7 +893,7 @@ INT_PTR CALLBACK EditorProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
rstring name = _r_ctrl_gettext (hpage_general, IDC_RULE_NAME_ID);
|
||||
|
||||
_r_str_trim (name, DIVIDER_TRIM DIVIDER_RULE);
|
||||
_r_str_alloc (&ptr_rule->pname, min (name.GetLength (), RULE_NAME_CCH_MAX), name);
|
||||
_r_str_alloc (&ptr_rule->pname, min (name.GetLength (), RULE_NAME_CCH_MAX), name.GetString ());
|
||||
}
|
||||
|
||||
// rule (remote)
|
||||
@@ -916,7 +916,7 @@ INT_PTR CALLBACK EditorProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
}
|
||||
|
||||
_r_str_trim (buffer, DIVIDER_TRIM DIVIDER_RULE);
|
||||
_r_str_alloc (&ptr_rule->prule_remote, buffer.GetLength (), buffer);
|
||||
_r_str_alloc (&ptr_rule->prule_remote, buffer.GetLength (), buffer.GetString ());
|
||||
}
|
||||
|
||||
// rule (local)
|
||||
@@ -939,7 +939,7 @@ INT_PTR CALLBACK EditorProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
}
|
||||
|
||||
_r_str_trim (buffer, DIVIDER_TRIM DIVIDER_RULE);
|
||||
_r_str_alloc (&ptr_rule->prule_local, buffer.GetLength (), buffer);
|
||||
_r_str_alloc (&ptr_rule->prule_local, buffer.GetLength (), buffer.GetString ());
|
||||
}
|
||||
|
||||
ptr_rule->protocol = (UINT8)SendDlgItemMessage (hpage_general, IDC_RULE_PROTOCOL_ID, CB_GETITEMDATA, SendDlgItemMessage (hpage_general, IDC_RULE_PROTOCOL_ID, CB_GETCURSEL, 0, 0), 0);
|
||||
|
||||
+173
-147
@@ -82,12 +82,12 @@ BOOLEAN _app_formataddress (ADDRESS_FAMILY af, UINT8 proto, const PVOID paddr, U
|
||||
{
|
||||
if (af == AF_INET)
|
||||
{
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), _r_fmt (L"%hhu.%hhu.%hhu.%hhu.%s", p4addr->s_impno, p4addr->s_lh, p4addr->s_host, p4addr->s_net, DNS_IP4_REVERSE_DOMAIN_STRING_W));
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), _r_fmt (L"%hhu.%hhu.%hhu.%hhu.%s", p4addr->s_impno, p4addr->s_lh, p4addr->s_host, p4addr->s_net, DNS_IP4_REVERSE_DOMAIN_STRING_W).GetString ());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (INT i = sizeof (IN6_ADDR) - 1; i >= 0; i--)
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), _r_fmt (L"%hhx.%hhx.", p6addr->s6_addr[i] & 0xF, (p6addr->s6_addr[i] >> 4) & 0xF));
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), _r_fmt (L"%hhx.%hhx.", p6addr->s6_addr[i] & 0xF, (p6addr->s6_addr[i] >> 4) & 0xF).GetString ());
|
||||
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), DNS_IP6_REVERSE_DOMAIN_STRING_W);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ BOOLEAN _app_formataddress (ADDRESS_FAMILY af, UINT8 proto, const PVOID paddr, U
|
||||
else
|
||||
{
|
||||
if ((flags & FMTADDR_USE_PROTOCOL) != 0)
|
||||
_r_str_printf (formatted_address, RTL_NUMBER_OF (formatted_address), L"%s://", _app_getprotoname (proto, AF_UNSPEC).GetString ());
|
||||
_r_str_printf (formatted_address, RTL_NUMBER_OF (formatted_address), L"%s://", _app_getprotoname (proto, AF_UNSPEC, SZ_UNKNOWN).GetString ());
|
||||
|
||||
WCHAR addr_str[DNS_MAX_NAME_BUFFER_LENGTH] = {0};
|
||||
|
||||
@@ -112,7 +112,7 @@ BOOLEAN _app_formataddress (ADDRESS_FAMILY af, UINT8 proto, const PVOID paddr, U
|
||||
result = !IN6_IS_ADDR_UNSPECIFIED (p6addr);
|
||||
|
||||
if (result)
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), (af == AF_INET6) ? _r_fmt (L"[%s]", addr_str) : addr_str);
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), (af == AF_INET6) ? _r_fmt (L"[%s]", addr_str).GetString () : addr_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -122,7 +122,7 @@ BOOLEAN _app_formataddress (ADDRESS_FAMILY af, UINT8 proto, const PVOID paddr, U
|
||||
}
|
||||
|
||||
if (port && (flags & FMTADDR_USE_PROTOCOL) == 0)
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), _r_fmt (!_r_str_isempty (formatted_address) ? L":%" TEXT (PRIu16) : L"%" TEXT (PRIu16), port));
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), _r_fmt (!_r_str_isempty (formatted_address) ? L":%" TEXT (PRIu16) : L"%" TEXT (PRIu16), port).GetString ());
|
||||
}
|
||||
|
||||
if ((flags & FMTADDR_RESOLVE_HOST) != 0)
|
||||
@@ -141,7 +141,7 @@ BOOLEAN _app_formataddress (ADDRESS_FAMILY af, UINT8 proto, const PVOID paddr, U
|
||||
PR_OBJECT ptr_cache_object = _r_obj2_reference (phash);
|
||||
|
||||
if (ptr_cache_object->pdata)
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), _r_fmt (L" (%s)", (LPCWSTR)ptr_cache_object->pdata));
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), _r_fmt (L" (%s)", (LPCWSTR)ptr_cache_object->pdata).GetString ());
|
||||
|
||||
_r_obj2_dereference (ptr_cache_object);
|
||||
}
|
||||
@@ -154,7 +154,7 @@ BOOLEAN _app_formataddress (ADDRESS_FAMILY af, UINT8 proto, const PVOID paddr, U
|
||||
|
||||
if (_app_resolveaddress (af, paddr, &ptr_cache))
|
||||
{
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), _r_fmt (L" (%s)", ptr_cache));
|
||||
_r_str_cat (formatted_address, RTL_NUMBER_OF (formatted_address), _r_fmt (L" (%s)", ptr_cache).GetString ());
|
||||
|
||||
_app_freeobjects_map (cache_hosts, MAP_CACHE_MAX);
|
||||
|
||||
@@ -381,7 +381,7 @@ VOID _app_getdisplayname (SIZE_T app_hash, PITEM_APP ptr_app, LPWSTR* extracted_
|
||||
if (!_app_item_get (ptr_app->type, app_hash, &name, NULL, NULL, NULL))
|
||||
name = ptr_app->original_path;
|
||||
|
||||
_r_str_alloc (extracted_name, name.GetLength (), name);
|
||||
_r_str_alloc (extracted_name, name.GetLength (), name.GetString ());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -565,32 +565,32 @@ PR_OBJECT _app_getversioninfo (SIZE_T app_hash, const PITEM_APP ptr_app)
|
||||
|
||||
if (hglob)
|
||||
{
|
||||
LPVOID versionInfo = LockResource (hglob);
|
||||
PVOID versionInfo = LockResource (hglob);
|
||||
|
||||
if (versionInfo)
|
||||
{
|
||||
rstring buffer;
|
||||
|
||||
UINT vLen = 0, langD = 0;
|
||||
LPVOID retbuf = NULL;
|
||||
PVOID retbuf = NULL;
|
||||
|
||||
WCHAR author_entry[128] = {0};
|
||||
WCHAR description_entry[128] = {0};
|
||||
WCHAR authorEntry[128];
|
||||
WCHAR descriptionEntry[128];
|
||||
|
||||
if (VerQueryValue (versionInfo, L"\\VarFileInfo\\Translation", &retbuf, &vLen) && vLen == 4)
|
||||
{
|
||||
RtlCopyMemory (&langD, retbuf, vLen);
|
||||
|
||||
_r_str_printf (author_entry, RTL_NUMBER_OF (author_entry), L"\\StringFileInfo\\%02X%02X%02X%02X\\CompanyName", (langD & 0xff00) >> 8, langD & 0xff, (langD & 0xff000000) >> 24, (langD & 0xff0000) >> 16);
|
||||
_r_str_printf (description_entry, RTL_NUMBER_OF (description_entry), L"\\StringFileInfo\\%02X%02X%02X%02X\\FileDescription", (langD & 0xff00) >> 8, langD & 0xff, (langD & 0xff000000) >> 24, (langD & 0xff0000) >> 16);
|
||||
_r_str_printf (authorEntry, RTL_NUMBER_OF (authorEntry), L"\\StringFileInfo\\%02X%02X%02X%02X\\CompanyName", (langD & 0xff00) >> 8, langD & 0xff, (langD & 0xff000000) >> 24, (langD & 0xff0000) >> 16);
|
||||
_r_str_printf (descriptionEntry, RTL_NUMBER_OF (descriptionEntry), L"\\StringFileInfo\\%02X%02X%02X%02X\\FileDescription", (langD & 0xff00) >> 8, langD & 0xff, (langD & 0xff000000) >> 24, (langD & 0xff0000) >> 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
_r_str_printf (author_entry, RTL_NUMBER_OF (author_entry), L"\\StringFileInfo\\%04X04B0\\CompanyName", GetUserDefaultLangID ());
|
||||
_r_str_printf (description_entry, RTL_NUMBER_OF (description_entry), L"\\StringFileInfo\\%04X04B0\\FileDescription", GetUserDefaultLangID ());
|
||||
_r_str_printf (authorEntry, RTL_NUMBER_OF (authorEntry), L"\\StringFileInfo\\%04X04B0\\CompanyName", GetUserDefaultLangID ());
|
||||
_r_str_printf (descriptionEntry, RTL_NUMBER_OF (descriptionEntry), L"\\StringFileInfo\\%04X04B0\\FileDescription", GetUserDefaultLangID ());
|
||||
}
|
||||
|
||||
if (VerQueryValue (versionInfo, description_entry, &retbuf, &vLen))
|
||||
if (VerQueryValue (versionInfo, descriptionEntry, &retbuf, &vLen))
|
||||
{
|
||||
buffer.Append (SZ_TAB);
|
||||
buffer.Append ((LPCWSTR)retbuf);
|
||||
@@ -598,7 +598,7 @@ PR_OBJECT _app_getversioninfo (SIZE_T app_hash, const PITEM_APP ptr_app)
|
||||
UINT length = 0;
|
||||
VS_FIXEDFILEINFO* verInfo = NULL;
|
||||
|
||||
if (VerQueryValue (versionInfo, L"\\", (LPVOID*)&verInfo, &length))
|
||||
if (VerQueryValue (versionInfo, L"\\", (PVOID*)&verInfo, &length))
|
||||
{
|
||||
buffer.Append (_r_fmt (L" %d.%d", HIWORD (verInfo->dwFileVersionMS), LOWORD (verInfo->dwFileVersionMS)));
|
||||
|
||||
@@ -614,7 +614,7 @@ PR_OBJECT _app_getversioninfo (SIZE_T app_hash, const PITEM_APP ptr_app)
|
||||
buffer.Append (L"\r\n");
|
||||
}
|
||||
|
||||
if (VerQueryValue (versionInfo, author_entry, &retbuf, &vLen))
|
||||
if (VerQueryValue (versionInfo, authorEntry, &retbuf, &vLen))
|
||||
{
|
||||
buffer.Append (SZ_TAB);
|
||||
buffer.Append ((LPCWSTR)retbuf);
|
||||
@@ -626,7 +626,7 @@ PR_OBJECT _app_getversioninfo (SIZE_T app_hash, const PITEM_APP ptr_app)
|
||||
// get signature information
|
||||
LPWSTR ptr_cache = NULL;
|
||||
|
||||
if (_r_str_alloc (&ptr_cache, buffer.GetLength (), buffer))
|
||||
if (_r_str_alloc (&ptr_cache, buffer.GetLength (), buffer.GetString ()))
|
||||
{
|
||||
_app_freeobjects_map (cache_versions, MAP_CACHE_MAX);
|
||||
|
||||
@@ -647,7 +647,7 @@ PR_OBJECT _app_getversioninfo (SIZE_T app_hash, const PITEM_APP ptr_app)
|
||||
return ptr_cache_object;
|
||||
}
|
||||
|
||||
rstring _app_getservicename (UINT16 port, LPCWSTR empty_text)
|
||||
rstring _app_getservicename (UINT16 port, LPCWSTR default_value)
|
||||
{
|
||||
switch (port)
|
||||
{
|
||||
@@ -1317,10 +1317,10 @@ rstring _app_getservicename (UINT16 port, LPCWSTR empty_text)
|
||||
return L"traceroute";
|
||||
}
|
||||
|
||||
return empty_text;
|
||||
return default_value;
|
||||
}
|
||||
|
||||
rstring _app_getprotoname (UINT8 proto, ADDRESS_FAMILY af)
|
||||
rstring _app_getprotoname (UINT8 proto, ADDRESS_FAMILY af, LPCWSTR default_value)
|
||||
{
|
||||
switch (proto)
|
||||
{
|
||||
@@ -1394,10 +1394,10 @@ rstring _app_getprotoname (UINT8 proto, ADDRESS_FAMILY af)
|
||||
return L"sctp";
|
||||
}
|
||||
|
||||
return SZ_UNKNOWN;
|
||||
return default_value;
|
||||
}
|
||||
|
||||
rstring _app_getstatename (DWORD state, LPCWSTR default_value)
|
||||
rstring _app_getconnectionstatusname (DWORD state, LPCWSTR default_value)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
@@ -1441,21 +1441,38 @@ rstring _app_getstatename (DWORD state, LPCWSTR default_value)
|
||||
return default_value;
|
||||
}
|
||||
|
||||
rstring _app_getdirectionname (FWP_DIRECTION direction, BOOLEAN is_loopback)
|
||||
rstring _app_getdirectionname (FWP_DIRECTION direction, BOOLEAN is_loopback, BOOLEAN is_localized)
|
||||
{
|
||||
rstring result;
|
||||
|
||||
if (direction == FWP_DIRECTION_INBOUND)
|
||||
result = SZ_DIRECTION_IN;
|
||||
if (is_localized)
|
||||
{
|
||||
if (direction == FWP_DIRECTION_OUTBOUND)
|
||||
result = app.LocaleString (IDS_DIRECTION_1, NULL);
|
||||
|
||||
else if (direction == FWP_DIRECTION_OUTBOUND)
|
||||
result = SZ_DIRECTION_OUT;
|
||||
else if (direction == FWP_DIRECTION_INBOUND)
|
||||
result = app.LocaleString (IDS_DIRECTION_2, NULL);
|
||||
|
||||
else if (direction == FWP_DIRECTION_MAX)
|
||||
result = SZ_DIRECTION_ANY;
|
||||
else if (direction == FWP_DIRECTION_MAX)
|
||||
result = app.LocaleString (IDS_ANY, NULL);
|
||||
|
||||
if (is_loopback)
|
||||
result.Append (SZ_DIRECTION_LOOPBACK);
|
||||
if (is_loopback)
|
||||
result.AppendFormat (L" (%s)", SZ_DIRECTION_LOOPBACK);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (direction == FWP_DIRECTION_OUTBOUND)
|
||||
result = SZ_DIRECTION_OUT;
|
||||
|
||||
else if (direction == FWP_DIRECTION_INBOUND)
|
||||
result = SZ_DIRECTION_IN;
|
||||
|
||||
else if (direction == FWP_DIRECTION_MAX)
|
||||
result = SZ_DIRECTION_ANY;
|
||||
|
||||
if (is_loopback)
|
||||
result.Append (L"-" SZ_DIRECTION_LOOPBACK);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1568,14 +1585,14 @@ rstring _app_getnetworkpath (DWORD pid, PULONG64 pmodules, PINT picon_id, PSIZE_
|
||||
}
|
||||
}
|
||||
|
||||
*phash = _r_str_hash (proc_name);
|
||||
*phash = _r_str_hash (proc_name.GetString ());
|
||||
|
||||
if (!proc_name.IsEmpty ())
|
||||
{
|
||||
*picon_id = (INT)_app_getappinfo (*phash, InfoIconId);
|
||||
|
||||
if (!*picon_id)
|
||||
_app_getfileicon (proc_name, TRUE, picon_id, NULL);
|
||||
_app_getfileicon (proc_name.GetString (), TRUE, picon_id, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1596,7 +1613,7 @@ SIZE_T _app_getnetworkhash (ADDRESS_FAMILY af, DWORD pid, PVOID remote_addr, DWO
|
||||
if (local_addr)
|
||||
_app_formatip (af, local_addr, local_addr_str, RTL_NUMBER_OF (local_addr_str));
|
||||
|
||||
return _r_str_hash (_r_fmt (L"%" TEXT (PRIu8) L"_%" TEXT (PR_ULONG) L"_%s_%" TEXT (PR_ULONG) L"_%s_%" TEXT (PR_ULONG) L"_%" TEXT (PRIu8) L"_%" TEXT (PR_ULONG), af, pid, remote_addr_str, remote_port, local_addr_str, local_port, proto, state));
|
||||
return _r_str_hash (_r_fmt (L"%" TEXT (PRIu8) L"_%" TEXT (PR_ULONG) L"_%s_%" TEXT (PR_ULONG) L"_%s_%" TEXT (PR_ULONG) L"_%" TEXT (PRIu8) L"_%" TEXT (PR_ULONG), af, pid, remote_addr_str, remote_port, local_addr_str, local_port, proto, state).GetString ());
|
||||
}
|
||||
|
||||
BOOLEAN _app_isvalidconnection (ADDRESS_FAMILY af, const PVOID paddr)
|
||||
@@ -1633,14 +1650,23 @@ VOID _app_generate_connections (OBJECTS_NETWORK& ptr_map, HASHER_MAP& checker_ma
|
||||
{
|
||||
checker_map.clear ();
|
||||
|
||||
DWORD tableSize = 0;
|
||||
GetExtendedTcpTable (NULL, &tableSize, FALSE, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0);
|
||||
DWORD allocationSize = 0x4000;
|
||||
PVOID memoryAddress = _r_mem_allocatezero (allocationSize);
|
||||
|
||||
if (tableSize)
|
||||
DWORD requiredSize = 0;
|
||||
GetExtendedTcpTable (NULL, &requiredSize, FALSE, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0);
|
||||
|
||||
if (requiredSize)
|
||||
{
|
||||
PMIB_TCPTABLE_OWNER_MODULE tcp4Table = (PMIB_TCPTABLE_OWNER_MODULE)_r_mem_allocatezero (tableSize);
|
||||
if (allocationSize < requiredSize)
|
||||
{
|
||||
memoryAddress = _r_mem_reallocatezero (memoryAddress, requiredSize);
|
||||
allocationSize = requiredSize;
|
||||
}
|
||||
|
||||
if (GetExtendedTcpTable (tcp4Table, &tableSize, FALSE, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0) == NO_ERROR)
|
||||
PMIB_TCPTABLE_OWNER_MODULE tcp4Table = (PMIB_TCPTABLE_OWNER_MODULE)memoryAddress;
|
||||
|
||||
if (GetExtendedTcpTable (tcp4Table, &requiredSize, FALSE, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0) == NO_ERROR)
|
||||
{
|
||||
for (DWORD i = 0; i < tcp4Table->dwNumEntries; i++)
|
||||
{
|
||||
@@ -1650,14 +1676,11 @@ VOID _app_generate_connections (OBJECTS_NETWORK& ptr_map, HASHER_MAP& checker_ma
|
||||
remote_addr.S_un.S_addr = tcp4Table->table[i].dwRemoteAddr;
|
||||
local_addr.S_un.S_addr = tcp4Table->table[i].dwLocalAddr;
|
||||
|
||||
SIZE_T net_hash = _app_getnetworkhash (AF_INET, tcp4Table->table[i].dwOwningPid, &remote_addr, tcp4Table->table[i].dwRemotePort, &local_addr, tcp4Table->table[i].dwLocalPort, IPPROTO_TCP, tcp4Table->table[i].dwState);
|
||||
SIZE_T network_hash = _app_getnetworkhash (AF_INET, tcp4Table->table[i].dwOwningPid, &remote_addr, tcp4Table->table[i].dwRemotePort, &local_addr, tcp4Table->table[i].dwLocalPort, IPPROTO_TCP, tcp4Table->table[i].dwState);
|
||||
|
||||
if (!net_hash)
|
||||
continue;
|
||||
|
||||
if (ptr_map.find (net_hash) != ptr_map.end ())
|
||||
if (ptr_map.find (network_hash) != ptr_map.end ())
|
||||
{
|
||||
checker_map[net_hash] = FALSE;
|
||||
checker_map[network_hash] = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1665,7 +1688,7 @@ VOID _app_generate_connections (OBJECTS_NETWORK& ptr_map, HASHER_MAP& checker_ma
|
||||
|
||||
rstring path = _app_getnetworkpath (tcp4Table->table[i].dwOwningPid, tcp4Table->table[i].OwningModuleInfo, &ptr_network->icon_id, &ptr_network->app_hash);
|
||||
|
||||
_r_str_alloc (&ptr_network->path, path.GetLength (), path);
|
||||
_r_str_alloc (&ptr_network->path, path.GetLength (), path.GetString ());
|
||||
|
||||
ptr_network->af = AF_INET;
|
||||
ptr_network->protocol = IPPROTO_TCP;
|
||||
@@ -1684,33 +1707,34 @@ VOID _app_generate_connections (OBJECTS_NETWORK& ptr_map, HASHER_MAP& checker_ma
|
||||
ptr_network->is_connection = TRUE;
|
||||
}
|
||||
|
||||
ptr_map[net_hash] = ptr_network;
|
||||
checker_map[net_hash] = TRUE;
|
||||
ptr_map[network_hash] = ptr_network;
|
||||
checker_map[network_hash] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
_r_mem_free (tcp4Table);
|
||||
}
|
||||
|
||||
tableSize = 0;
|
||||
GetExtendedTcpTable (NULL, &tableSize, FALSE, AF_INET6, TCP_TABLE_OWNER_MODULE_ALL, 0);
|
||||
requiredSize = 0;
|
||||
GetExtendedTcpTable (NULL, &requiredSize, FALSE, AF_INET6, TCP_TABLE_OWNER_MODULE_ALL, 0);
|
||||
|
||||
if (tableSize)
|
||||
if (requiredSize)
|
||||
{
|
||||
PMIB_TCP6TABLE_OWNER_MODULE tcp6Table = (PMIB_TCP6TABLE_OWNER_MODULE)_r_mem_allocatezero (tableSize);
|
||||
if (allocationSize < requiredSize)
|
||||
{
|
||||
memoryAddress = _r_mem_reallocate (memoryAddress, requiredSize);
|
||||
allocationSize = requiredSize;
|
||||
}
|
||||
|
||||
if (GetExtendedTcpTable (tcp6Table, &tableSize, FALSE, AF_INET6, TCP_TABLE_OWNER_MODULE_ALL, 0) == NO_ERROR)
|
||||
PMIB_TCP6TABLE_OWNER_MODULE tcp6Table = (PMIB_TCP6TABLE_OWNER_MODULE)memoryAddress;
|
||||
|
||||
if (GetExtendedTcpTable (tcp6Table, &requiredSize, FALSE, AF_INET6, TCP_TABLE_OWNER_MODULE_ALL, 0) == NO_ERROR)
|
||||
{
|
||||
for (DWORD i = 0; i < tcp6Table->dwNumEntries; i++)
|
||||
{
|
||||
SIZE_T net_hash = _app_getnetworkhash (AF_INET6, tcp6Table->table[i].dwOwningPid, tcp6Table->table[i].ucRemoteAddr, tcp6Table->table[i].dwRemotePort, tcp6Table->table[i].ucLocalAddr, tcp6Table->table[i].dwLocalPort, IPPROTO_TCP, tcp6Table->table[i].dwState);
|
||||
SIZE_T network_hash = _app_getnetworkhash (AF_INET6, tcp6Table->table[i].dwOwningPid, tcp6Table->table[i].ucRemoteAddr, tcp6Table->table[i].dwRemotePort, tcp6Table->table[i].ucLocalAddr, tcp6Table->table[i].dwLocalPort, IPPROTO_TCP, tcp6Table->table[i].dwState);
|
||||
|
||||
if (!net_hash)
|
||||
continue;
|
||||
|
||||
if (ptr_map.find (net_hash) != ptr_map.end ())
|
||||
if (ptr_map.find (network_hash) != ptr_map.end ())
|
||||
{
|
||||
checker_map[net_hash] = FALSE;
|
||||
checker_map[network_hash] = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1718,7 +1742,7 @@ VOID _app_generate_connections (OBJECTS_NETWORK& ptr_map, HASHER_MAP& checker_ma
|
||||
|
||||
rstring path = _app_getnetworkpath (tcp6Table->table[i].dwOwningPid, tcp6Table->table[i].OwningModuleInfo, &ptr_network->icon_id, &ptr_network->app_hash);
|
||||
|
||||
_r_str_alloc (&ptr_network->path, path.GetLength (), path);
|
||||
_r_str_alloc (&ptr_network->path, path.GetLength (), path.GetString ());
|
||||
|
||||
ptr_network->af = AF_INET6;
|
||||
ptr_network->protocol = IPPROTO_TCP;
|
||||
@@ -1737,36 +1761,37 @@ VOID _app_generate_connections (OBJECTS_NETWORK& ptr_map, HASHER_MAP& checker_ma
|
||||
ptr_network->is_connection = TRUE;
|
||||
}
|
||||
|
||||
ptr_map[net_hash] = ptr_network;
|
||||
checker_map[net_hash] = TRUE;
|
||||
ptr_map[network_hash] = ptr_network;
|
||||
checker_map[network_hash] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
_r_mem_free (tcp6Table);
|
||||
}
|
||||
|
||||
tableSize = 0;
|
||||
GetExtendedUdpTable (NULL, &tableSize, FALSE, AF_INET, UDP_TABLE_OWNER_MODULE, 0);
|
||||
requiredSize = 0;
|
||||
GetExtendedUdpTable (NULL, &requiredSize, FALSE, AF_INET, UDP_TABLE_OWNER_MODULE, 0);
|
||||
|
||||
if (tableSize)
|
||||
if (requiredSize)
|
||||
{
|
||||
PMIB_UDPTABLE_OWNER_MODULE udp4Table = (PMIB_UDPTABLE_OWNER_MODULE)_r_mem_allocatezero (tableSize);
|
||||
if (allocationSize < requiredSize)
|
||||
{
|
||||
memoryAddress = _r_mem_reallocate (memoryAddress, requiredSize);
|
||||
allocationSize = requiredSize;
|
||||
}
|
||||
|
||||
if (GetExtendedUdpTable (udp4Table, &tableSize, FALSE, AF_INET, UDP_TABLE_OWNER_MODULE, 0) == NO_ERROR)
|
||||
PMIB_UDPTABLE_OWNER_MODULE udp4Table = (PMIB_UDPTABLE_OWNER_MODULE)memoryAddress;
|
||||
|
||||
if (GetExtendedUdpTable (udp4Table, &requiredSize, FALSE, AF_INET, UDP_TABLE_OWNER_MODULE, 0) == NO_ERROR)
|
||||
{
|
||||
for (DWORD i = 0; i < udp4Table->dwNumEntries; i++)
|
||||
{
|
||||
IN_ADDR local_addr = {0};
|
||||
local_addr.S_un.S_addr = udp4Table->table[i].dwLocalAddr;
|
||||
|
||||
SIZE_T net_hash = _app_getnetworkhash (AF_INET, udp4Table->table[i].dwOwningPid, NULL, 0, &local_addr, udp4Table->table[i].dwLocalPort, IPPROTO_UDP, 0);
|
||||
SIZE_T network_hash = _app_getnetworkhash (AF_INET, udp4Table->table[i].dwOwningPid, NULL, 0, &local_addr, udp4Table->table[i].dwLocalPort, IPPROTO_UDP, 0);
|
||||
|
||||
if (!net_hash)
|
||||
continue;
|
||||
|
||||
if (ptr_map.find (net_hash) != ptr_map.end ())
|
||||
if (ptr_map.find (network_hash) != ptr_map.end ())
|
||||
{
|
||||
checker_map[net_hash] = FALSE;
|
||||
checker_map[network_hash] = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1774,7 +1799,7 @@ VOID _app_generate_connections (OBJECTS_NETWORK& ptr_map, HASHER_MAP& checker_ma
|
||||
|
||||
rstring path = _app_getnetworkpath (udp4Table->table[i].dwOwningPid, udp4Table->table[i].OwningModuleInfo, &ptr_network->icon_id, &ptr_network->app_hash);
|
||||
|
||||
_r_str_alloc (&ptr_network->path, path.GetLength (), path);
|
||||
_r_str_alloc (&ptr_network->path, path.GetLength (), path.GetString ());
|
||||
|
||||
ptr_network->af = AF_INET;
|
||||
ptr_network->protocol = IPPROTO_UDP;
|
||||
@@ -1787,33 +1812,35 @@ VOID _app_generate_connections (OBJECTS_NETWORK& ptr_map, HASHER_MAP& checker_ma
|
||||
if (_app_isvalidconnection (ptr_network->af, &ptr_network->local_addr))
|
||||
ptr_network->is_connection = TRUE;
|
||||
|
||||
ptr_map[net_hash] = ptr_network;
|
||||
checker_map[net_hash] = TRUE;
|
||||
ptr_map[network_hash] = ptr_network;
|
||||
checker_map[network_hash] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
_r_mem_free (udp4Table);
|
||||
}
|
||||
|
||||
tableSize = 0;
|
||||
GetExtendedUdpTable (NULL, &tableSize, FALSE, AF_INET6, UDP_TABLE_OWNER_MODULE, 0);
|
||||
requiredSize = 0;
|
||||
GetExtendedUdpTable (NULL, &requiredSize, FALSE, AF_INET6, UDP_TABLE_OWNER_MODULE, 0);
|
||||
|
||||
if (tableSize)
|
||||
if (requiredSize)
|
||||
{
|
||||
PMIB_UDP6TABLE_OWNER_MODULE udp6Table = (PMIB_UDP6TABLE_OWNER_MODULE)_r_mem_allocatezero (tableSize);
|
||||
if (allocationSize < requiredSize)
|
||||
{
|
||||
memoryAddress = _r_mem_reallocate (memoryAddress, requiredSize);
|
||||
allocationSize = requiredSize;
|
||||
}
|
||||
|
||||
if (GetExtendedUdpTable (udp6Table, &tableSize, FALSE, AF_INET6, UDP_TABLE_OWNER_MODULE, 0) == NO_ERROR)
|
||||
PMIB_UDP6TABLE_OWNER_MODULE udp6Table = (PMIB_UDP6TABLE_OWNER_MODULE)memoryAddress;
|
||||
|
||||
if (GetExtendedUdpTable (udp6Table, &requiredSize, FALSE, AF_INET6, UDP_TABLE_OWNER_MODULE, 0) == NO_ERROR)
|
||||
{
|
||||
for (DWORD i = 0; i < udp6Table->dwNumEntries; i++)
|
||||
{
|
||||
SIZE_T net_hash = _app_getnetworkhash (AF_INET6, udp6Table->table[i].dwOwningPid, NULL, 0, udp6Table->table[i].ucLocalAddr, udp6Table->table[i].dwLocalPort, IPPROTO_UDP, 0);
|
||||
SIZE_T network_hash = _app_getnetworkhash (AF_INET6, udp6Table->table[i].dwOwningPid, NULL, 0, udp6Table->table[i].ucLocalAddr, udp6Table->table[i].dwLocalPort, IPPROTO_UDP, 0);
|
||||
|
||||
if (!net_hash)
|
||||
continue;
|
||||
|
||||
if (ptr_map.find (net_hash) != ptr_map.end ())
|
||||
if (ptr_map.find (network_hash) != ptr_map.end ())
|
||||
{
|
||||
checker_map[net_hash] = FALSE;
|
||||
checker_map[network_hash] = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1821,7 +1848,7 @@ VOID _app_generate_connections (OBJECTS_NETWORK& ptr_map, HASHER_MAP& checker_ma
|
||||
|
||||
rstring path = _app_getnetworkpath (udp6Table->table[i].dwOwningPid, udp6Table->table[i].OwningModuleInfo, &ptr_network->icon_id, &ptr_network->app_hash);
|
||||
|
||||
_r_str_alloc (&ptr_network->path, path.GetLength (), path);
|
||||
_r_str_alloc (&ptr_network->path, path.GetLength (), path.GetString ());
|
||||
|
||||
ptr_network->af = AF_INET6;
|
||||
ptr_network->protocol = IPPROTO_UDP;
|
||||
@@ -1834,23 +1861,23 @@ VOID _app_generate_connections (OBJECTS_NETWORK& ptr_map, HASHER_MAP& checker_ma
|
||||
if (_app_isvalidconnection (ptr_network->af, &ptr_network->local_addr6))
|
||||
ptr_network->is_connection = TRUE;
|
||||
|
||||
ptr_map[net_hash] = ptr_network;
|
||||
checker_map[net_hash] = TRUE;
|
||||
ptr_map[network_hash] = ptr_network;
|
||||
checker_map[network_hash] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
_r_mem_free (udp6Table);
|
||||
}
|
||||
|
||||
if (memoryAddress)
|
||||
_r_mem_free (memoryAddress);
|
||||
}
|
||||
|
||||
VOID _app_generate_packages ()
|
||||
{
|
||||
HKEY hkey = NULL;
|
||||
HKEY hsubkey = NULL;
|
||||
HKEY hkey;
|
||||
|
||||
LONG rc = RegOpenKeyEx (HKEY_CLASSES_ROOT, L"Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\AppModel\\Repository\\Packages", 0, KEY_READ, &hkey);
|
||||
LONG code = RegOpenKeyEx (HKEY_CLASSES_ROOT, L"Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\AppModel\\Repository\\Packages", 0, KEY_READ, &hkey);
|
||||
|
||||
if (rc == ERROR_SUCCESS)
|
||||
if (code == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD index = 0;
|
||||
DWORD max_length = _r_reg_querysubkeylength (hkey);
|
||||
@@ -1861,6 +1888,7 @@ VOID _app_generate_packages ()
|
||||
return;
|
||||
}
|
||||
|
||||
HKEY hsubkey;
|
||||
LPWSTR key_name = (LPWSTR)_r_mem_allocatezero ((max_length + 1) * sizeof (WCHAR));
|
||||
|
||||
while (TRUE)
|
||||
@@ -1870,9 +1898,9 @@ VOID _app_generate_packages ()
|
||||
if (RegEnumKeyEx (hkey, index++, key_name, &size, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
|
||||
break;
|
||||
|
||||
rc = RegOpenKeyEx (hkey, key_name, 0, KEY_READ, &hsubkey);
|
||||
code = RegOpenKeyEx (hkey, key_name, 0, KEY_READ, &hsubkey);
|
||||
|
||||
if (rc == ERROR_SUCCESS)
|
||||
if (code == ERROR_SUCCESS)
|
||||
{
|
||||
LPBYTE package_sid = _r_reg_querybinary (hsubkey, L"PackageSid");
|
||||
|
||||
@@ -1892,7 +1920,7 @@ VOID _app_generate_packages ()
|
||||
continue;
|
||||
}
|
||||
|
||||
SIZE_T app_hash = _r_str_hash (package_sid_string);
|
||||
SIZE_T app_hash = _r_str_hash (package_sid_string.GetString ());
|
||||
|
||||
if (_app_isapphelperfound (app_hash))
|
||||
{
|
||||
@@ -1908,9 +1936,9 @@ VOID _app_generate_packages ()
|
||||
{
|
||||
if (display_name.At (0) == L'@')
|
||||
{
|
||||
WCHAR name[MAX_PATH] = {0};
|
||||
WCHAR name[MAX_PATH];
|
||||
|
||||
if (SUCCEEDED (SHLoadIndirectString (display_name, name, RTL_NUMBER_OF (name), NULL)))
|
||||
if (SUCCEEDED (SHLoadIndirectString (display_name.GetString (), name, RTL_NUMBER_OF (name), NULL)))
|
||||
display_name = name;
|
||||
|
||||
else
|
||||
@@ -1937,12 +1965,12 @@ VOID _app_generate_packages ()
|
||||
rstring path = _r_reg_querystring (hsubkey, L"PackageRootFolder");
|
||||
|
||||
if (!path.IsEmpty ())
|
||||
_r_str_alloc (&ptr_item->real_path, path.GetLength (), path);
|
||||
_r_str_alloc (&ptr_item->real_path, path.GetLength (), path.GetString ());
|
||||
|
||||
RegCloseKey (hsubkey);
|
||||
|
||||
_r_str_alloc (&ptr_item->display_name, display_name.GetLength (), display_name);
|
||||
_r_str_alloc (&ptr_item->internal_name, package_sid_string.GetLength (), package_sid_string);
|
||||
_r_str_alloc (&ptr_item->display_name, display_name.GetLength (), display_name.GetString ());
|
||||
_r_str_alloc (&ptr_item->internal_name, package_sid_string.GetLength (), package_sid_string.GetString ());
|
||||
|
||||
// load additional info from appx manifest
|
||||
_app_load_appxmanifest (ptr_item);
|
||||
@@ -1976,7 +2004,7 @@ VOID _app_generate_services ()
|
||||
dwServiceType |= SERVICE_INTERACTIVE_PROCESS | SERVICE_USER_SERVICE | SERVICE_USERSERVICE_INSTANCE;
|
||||
|
||||
DWORD bufferSize = initialBufferSize;
|
||||
LPVOID pBuffer = _r_mem_allocatezero (bufferSize);
|
||||
PVOID pBuffer = _r_mem_allocatezero (bufferSize);
|
||||
|
||||
if (!pBuffer)
|
||||
return;
|
||||
@@ -2029,7 +2057,7 @@ VOID _app_generate_services ()
|
||||
{
|
||||
HKEY hkey = NULL;
|
||||
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, _r_fmt (L"System\\CurrentControlSet\\Services\\%s\\Parameters", service_name), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, _r_fmt (L"System\\CurrentControlSet\\Services\\%s\\Parameters", service_name).GetString (), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
||||
{
|
||||
// query path
|
||||
real_path = _r_reg_querystring (hkey, L"ServiceDll");
|
||||
@@ -2046,7 +2074,7 @@ VOID _app_generate_services ()
|
||||
{
|
||||
HKEY hkey = NULL;
|
||||
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, _r_fmt (L"System\\CurrentControlSet\\Services\\%s", service_name), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, _r_fmt (L"System\\CurrentControlSet\\Services\\%s", service_name).GetString (), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
||||
{
|
||||
// query path
|
||||
if (real_path.IsEmpty ())
|
||||
@@ -2072,7 +2100,7 @@ VOID _app_generate_services ()
|
||||
}
|
||||
|
||||
if (!real_path.IsEmpty ())
|
||||
real_path = _r_path_dospathfromnt (real_path);
|
||||
real_path = _r_path_dospathfromnt (real_path.GetString ());
|
||||
|
||||
PSID pserviceSid = _app_queryservicesid (service_name);
|
||||
|
||||
@@ -2105,7 +2133,7 @@ VOID _app_generate_services ()
|
||||
ptr_item->timestamp = timestamp;
|
||||
|
||||
_r_str_alloc (&ptr_item->display_name, _r_str_length (display_name), display_name);
|
||||
_r_str_alloc (&ptr_item->real_path, real_path.GetLength (), real_path);
|
||||
_r_str_alloc (&ptr_item->real_path, real_path.GetLength (), real_path.GetString ());
|
||||
_r_str_alloc (&ptr_item->internal_name, _r_str_length (service_name), service_name);
|
||||
|
||||
ptr_item->pdata = _r_mem_allocatezero (sd_length);
|
||||
@@ -2134,7 +2162,7 @@ VOID _app_generate_rulesmenu (HMENU hsubmenu, SIZE_T app_hash)
|
||||
if (!app_hash || !pstatus->rules_count)
|
||||
{
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
AppendMenu (hsubmenu, MF_STRING, IDX_RULES_SPECIAL, app.LocaleString (IDS_STATUS_EMPTY, NULL));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDX_RULES_SPECIAL, app.LocaleString (IDS_STATUS_EMPTY, NULL).GetString ());
|
||||
|
||||
_r_menu_enableitem (hsubmenu, IDX_RULES_SPECIAL, MF_BYCOMMAND, FALSE);
|
||||
}
|
||||
@@ -2184,8 +2212,8 @@ VOID _app_generate_rulesmenu (HMENU hsubmenu, SIZE_T app_hash)
|
||||
continue;
|
||||
}
|
||||
|
||||
WCHAR buffer[128] = {0};
|
||||
_r_str_printf (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_RULE_APPLY_2, ptr_rule->is_readonly ? SZ_RULE_INTERNAL_MENU : NULL), ptr_rule->pname);
|
||||
WCHAR buffer[128];
|
||||
_r_str_printf (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_RULE_APPLY_2, ptr_rule->is_readonly ? SZ_RULE_INTERNAL_MENU : NULL).GetString (), ptr_rule->pname);
|
||||
|
||||
MENUITEMINFO mii = {0};
|
||||
|
||||
@@ -2209,8 +2237,8 @@ VOID _app_generate_rulesmenu (HMENU hsubmenu, SIZE_T app_hash)
|
||||
}
|
||||
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_EDITRULES, app.LocaleString (IDS_EDITRULES, NULL));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_OPENRULESEDITOR, app.LocaleString (IDS_OPENRULESEDITOR, L"..."));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_EDITRULES, app.LocaleString (IDS_EDITRULES, NULL).GetString ());
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_OPENRULESEDITOR, app.LocaleString (IDS_OPENRULESEDITOR, L"...").GetString ());
|
||||
|
||||
_r_mem_free (pstatus);
|
||||
}
|
||||
@@ -2228,7 +2256,7 @@ VOID _app_generate_timermenu (HMENU hsubmenu, SIZE_T app_hash)
|
||||
UINT menu_id = IDX_TIMER + (UINT)i;
|
||||
time_t timer = timers.at (i);
|
||||
|
||||
AppendMenu (hsubmenu, MF_STRING, menu_id, _r_fmt_interval (timer + 1, 1));
|
||||
AppendMenu (hsubmenu, MF_STRING, menu_id, _r_fmt_interval (timer + 1, 1).GetString ());
|
||||
|
||||
if (!is_checked && (app_time > current_time) && (app_time <= (current_time + timer)))
|
||||
{
|
||||
@@ -2241,7 +2269,7 @@ VOID _app_generate_timermenu (HMENU hsubmenu, SIZE_T app_hash)
|
||||
_r_menu_checkitem (hsubmenu, IDM_DISABLETIMER, IDM_DISABLETIMER, MF_BYCOMMAND, IDM_DISABLETIMER);
|
||||
}
|
||||
|
||||
BOOLEAN _app_item_get (ENUM_TYPE_DATA type, SIZE_T app_hash, rstring* display_name, rstring* real_path, time_t* ptime, LPVOID* lpdata)
|
||||
BOOLEAN _app_item_get (ENUM_TYPE_DATA type, SIZE_T app_hash, rstring* display_name, rstring* real_path, time_t* ptime, PVOID* lpdata)
|
||||
{
|
||||
PITEM_APP_HELPER ptr_app_item = _app_getapphelperitem (app_hash);
|
||||
|
||||
@@ -2306,7 +2334,7 @@ rstring _app_parsehostaddress_dns (LPCWSTR hostname, USHORT port)
|
||||
for (auto ¤t = ppQueryResultsSet; current != NULL; current = current->pNext)
|
||||
{
|
||||
// ipv4 address
|
||||
WCHAR str[INET_ADDRSTRLEN] = {0};
|
||||
WCHAR str[INET_ADDRSTRLEN];
|
||||
|
||||
if (_app_formatip (AF_INET, &(current->Data.A.IpAddress), str, RTL_NUMBER_OF (str)))
|
||||
{
|
||||
@@ -2337,7 +2365,7 @@ rstring _app_parsehostaddress_dns (LPCWSTR hostname, USHORT port)
|
||||
{
|
||||
for (auto ¤t = ppQueryResultsSet; current != NULL; current = current->pNext)
|
||||
{
|
||||
WCHAR str[INET6_ADDRSTRLEN] = {0};
|
||||
WCHAR str[INET6_ADDRSTRLEN];
|
||||
|
||||
if (_app_formatip (AF_INET6, &(current->Data.AAAA.Ip6Address), str, RTL_NUMBER_OF (str)))
|
||||
{
|
||||
@@ -2440,11 +2468,11 @@ BOOLEAN _app_parsenetworkstring (LPCWSTR network_string, NET_ADDRESS_FORMAT* for
|
||||
}
|
||||
else
|
||||
{
|
||||
_r_str_copy (paddr_dns, dns_length, host);
|
||||
_r_str_copy (paddr_dns, dns_length, host.GetString ());
|
||||
|
||||
LPWSTR ptr_cache = NULL;
|
||||
|
||||
if (_r_str_alloc (&ptr_cache, host.GetLength (), host))
|
||||
if (_r_str_alloc (&ptr_cache, host.GetLength (), host.GetString ()))
|
||||
{
|
||||
_app_freeobjects_map (cache_dns, MAP_CACHE_MAX);
|
||||
|
||||
@@ -2469,11 +2497,11 @@ BOOLEAN _app_parserulestring (rstring rule, PITEM_ADDRESS ptr_addr)
|
||||
if (rule.IsEmpty ())
|
||||
return TRUE;
|
||||
|
||||
if (!_app_isrulevalidchars (rule))
|
||||
if (!_app_isrulevalidchars (rule.GetString ()))
|
||||
return FALSE;
|
||||
|
||||
ENUM_TYPE_DATA type = DataUnknown;
|
||||
SIZE_T range_pos = _r_str_find (rule, rule.GetLength (), DIVIDER_RULE_RANGE, 0);
|
||||
SIZE_T range_pos = _r_str_find (rule.GetString (), rule.GetLength (), DIVIDER_RULE_RANGE, 0);
|
||||
BOOLEAN is_range = (range_pos != INVALID_SIZE_T);
|
||||
|
||||
WCHAR range_start[LEN_IP_MAX] = {0};
|
||||
@@ -2481,13 +2509,13 @@ BOOLEAN _app_parserulestring (rstring rule, PITEM_ADDRESS ptr_addr)
|
||||
|
||||
if (is_range)
|
||||
{
|
||||
_r_str_copy (range_start, RTL_NUMBER_OF (range_start), _r_str_extract (rule, rule.GetLength (), 0, range_pos));
|
||||
_r_str_copy (range_end, RTL_NUMBER_OF (range_end), _r_str_extract (rule, rule.GetLength (), range_pos + 1));
|
||||
_r_str_copy (range_start, RTL_NUMBER_OF (range_start), _r_str_extract (rule.GetString (), rule.GetLength (), 0, range_pos).GetString ());
|
||||
_r_str_copy (range_end, RTL_NUMBER_OF (range_end), _r_str_extract (rule.GetString (), rule.GetLength (), range_pos + 1).GetString ());
|
||||
}
|
||||
|
||||
// auto-parse rule type
|
||||
{
|
||||
SIZE_T rule_hash = _r_str_hash (rule);
|
||||
SIZE_T rule_hash = _r_str_hash (rule.GetString ());
|
||||
BOOLEAN is_exists = cache_types.find (rule_hash) != cache_types.end ();
|
||||
|
||||
if (is_exists)
|
||||
@@ -2496,15 +2524,15 @@ BOOLEAN _app_parserulestring (rstring rule, PITEM_ADDRESS ptr_addr)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_app_isruleport (rule))
|
||||
if (_app_isruleport (rule.GetString ()))
|
||||
{
|
||||
type = DataTypePort;
|
||||
}
|
||||
else if (is_range ? (_app_isruleip (range_start) && _app_isruleip (range_end)) : _app_isruleip (rule))
|
||||
else if (is_range ? (_app_isruleip (range_start) && _app_isruleip (range_end)) : _app_isruleip (rule.GetString ()))
|
||||
{
|
||||
type = DataTypeIp;
|
||||
}
|
||||
else if (_app_isrulehost (rule))
|
||||
else if (_app_isrulehost (rule.GetString ()))
|
||||
{
|
||||
type = DataTypeHost;
|
||||
}
|
||||
@@ -2536,7 +2564,7 @@ BOOLEAN _app_parserulestring (rstring rule, PITEM_ADDRESS ptr_addr)
|
||||
{
|
||||
// ...port
|
||||
ptr_addr->type = DataTypePort;
|
||||
ptr_addr->port = (UINT16)_r_str_touinteger (rule);
|
||||
ptr_addr->port = (UINT16)_r_str_touinteger (rule.GetString ());
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2635,7 +2663,7 @@ BOOLEAN _app_parserulestring (rstring rule, PITEM_ADDRESS ptr_addr)
|
||||
else
|
||||
{
|
||||
// ...ip/host
|
||||
if (_app_parsenetworkstring (rule, &format, &port2, &addr4, &addr6, ptr_addr->host, RTL_NUMBER_OF (ptr_addr->host)))
|
||||
if (_app_parsenetworkstring (rule.GetString (), &format, &port2, &addr4, &addr6, ptr_addr->host, RTL_NUMBER_OF (ptr_addr->host)))
|
||||
{
|
||||
if (format == NET_ADDRESS_IPV4)
|
||||
{
|
||||
@@ -2680,7 +2708,7 @@ BOOLEAN _app_parserulestring (rstring rule, PITEM_ADDRESS ptr_addr)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN _app_resolveaddress (ADDRESS_FAMILY af, LPVOID paddr, LPWSTR* pbuffer)
|
||||
BOOLEAN _app_resolveaddress (ADDRESS_FAMILY af, PVOID paddr, LPWSTR* pbuffer)
|
||||
{
|
||||
if (af != AF_INET && af != AF_INET6)
|
||||
return FALSE;
|
||||
@@ -2771,10 +2799,8 @@ HBITMAP _app_bitmapfromico (HICON hicon, INT icon_size)
|
||||
if (!hicon)
|
||||
return NULL;
|
||||
|
||||
RECT iconRectangle = {0};
|
||||
|
||||
iconRectangle.right = icon_size;
|
||||
iconRectangle.bottom = icon_size;
|
||||
RECT iconRectangle;
|
||||
SetRect (&iconRectangle, 0, 0, icon_size, icon_size);
|
||||
|
||||
HBITMAP hbitmap = NULL;
|
||||
HDC screenHdc = GetDC (NULL);
|
||||
@@ -2858,7 +2884,7 @@ HBITMAP _app_bitmapfrompng (HINSTANCE hinst, LPCWSTR name, INT icon_size)
|
||||
WICRect rect = {0, 0, icon_size, icon_size};
|
||||
|
||||
// Create the ImagingFactory
|
||||
if (FAILED (CoCreateInstance (CLSID_WICImagingFactory1, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*)&wicFactory)))
|
||||
if (FAILED (CoCreateInstance (CLSID_WICImagingFactory1, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (PVOID*)&wicFactory)))
|
||||
goto DoExit;
|
||||
|
||||
// Load the resource
|
||||
@@ -2999,7 +3025,7 @@ VOID _app_load_appxmanifest (PITEM_APP_HELPER ptr_app_item)
|
||||
{
|
||||
path.Format (L"%s\\%s", ptr_app_item->real_path, appx_names[i]);
|
||||
|
||||
if (_r_fs_exists (path))
|
||||
if (_r_fs_exists (path.GetString ()))
|
||||
goto DoOpen;
|
||||
}
|
||||
|
||||
@@ -3008,7 +3034,7 @@ VOID _app_load_appxmanifest (PITEM_APP_HELPER ptr_app_item)
|
||||
DoOpen:
|
||||
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result xml_result = doc.load_file (path, PUGIXML_LOAD_FLAGS, PUGIXML_LOAD_ENCODING);
|
||||
pugi::xml_parse_result xml_result = doc.load_file (path.GetString (), PUGIXML_LOAD_FLAGS, PUGIXML_LOAD_ENCODING);
|
||||
|
||||
if (xml_result)
|
||||
{
|
||||
@@ -3024,7 +3050,7 @@ DoOpen:
|
||||
{
|
||||
result.Format (L"%s\\%s", ptr_app_item->real_path, item.attribute (L"Executable").as_string ());
|
||||
|
||||
if (_r_fs_exists (result))
|
||||
if (_r_fs_exists (result.GetString ()))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -32,10 +32,10 @@ VOID _app_getdisplayname (SIZE_T app_hash, PITEM_APP ptr_app, LPWSTR* extracted_
|
||||
BOOLEAN _app_getfileicon (LPCWSTR path, BOOLEAN is_small, PINT picon_id, HICON* picon);
|
||||
PR_OBJECT _app_getsignatureinfo (SIZE_T app_hash, const PITEM_APP ptr_app);
|
||||
PR_OBJECT _app_getversioninfo (SIZE_T app_hash, const PITEM_APP ptr_app);
|
||||
rstring _app_getservicename (UINT16 port, LPCWSTR empty_text);
|
||||
rstring _app_getprotoname (UINT8 proto, ADDRESS_FAMILY af);
|
||||
rstring _app_getstatename (DWORD state, LPCWSTR default_value);
|
||||
rstring _app_getdirectionname (FWP_DIRECTION direction, BOOLEAN is_loopback);
|
||||
rstring _app_getservicename (UINT16 port, LPCWSTR default_value);
|
||||
rstring _app_getprotoname (UINT8 proto, ADDRESS_FAMILY af, LPCWSTR default_value);
|
||||
rstring _app_getconnectionstatusname (DWORD state, LPCWSTR default_value);
|
||||
rstring _app_getdirectionname (FWP_DIRECTION direction, BOOLEAN is_loopback, BOOLEAN is_localized);
|
||||
rstring _app_getfiltername (LPCWSTR provider_name, LPCWSTR filter_name, LPCWSTR default_value);
|
||||
COLORREF _app_getcolorvalue (SIZE_T color_hash);
|
||||
|
||||
@@ -46,14 +46,14 @@ VOID _app_generate_services ();
|
||||
VOID _app_generate_rulesmenu (HMENU hsubmenu, SIZE_T app_hash);
|
||||
VOID _app_generate_timermenu (HMENU hsubmenu, SIZE_T app_hash);
|
||||
|
||||
BOOLEAN _app_item_get (ENUM_TYPE_DATA type, SIZE_T app_hash, rstring* display_name, rstring* real_path, time_t* ptime, LPVOID* lpdata);
|
||||
BOOLEAN _app_item_get (ENUM_TYPE_DATA type, SIZE_T app_hash, rstring* display_name, rstring* real_path, time_t* ptime, PVOID* lpdata);
|
||||
|
||||
rstring _app_parsehostaddress_dns (LPCWSTR hostname, USHORT port);
|
||||
|
||||
BOOLEAN _app_parsenetworkstring (LPCWSTR network_string, NET_ADDRESS_FORMAT* format_ptr, PUSHORT port_ptr, FWP_V4_ADDR_AND_MASK* paddr4, FWP_V6_ADDR_AND_MASK* paddr6, LPWSTR paddr_dns, SIZE_T dns_length);
|
||||
BOOLEAN _app_parserulestring (rstring rule, PITEM_ADDRESS ptr_addr);
|
||||
|
||||
BOOLEAN _app_resolveaddress (ADDRESS_FAMILY af, LPVOID paddr, LPWSTR* pbuffer);
|
||||
BOOLEAN _app_resolveaddress (ADDRESS_FAMILY af, PVOID paddr, LPWSTR* pbuffer);
|
||||
|
||||
INT _app_getlistview_id (ENUM_TYPE_DATA type);
|
||||
|
||||
|
||||
+32
-32
@@ -10,7 +10,7 @@ rstring _app_getlogviewer ()
|
||||
if (result.IsEmpty ())
|
||||
return _r_path_expand (LOG_VIEWER_DEFAULT);
|
||||
|
||||
return _r_path_expand (result);
|
||||
return _r_path_expand (result.GetString ());
|
||||
}
|
||||
|
||||
VOID _app_loginit (BOOLEAN is_install)
|
||||
@@ -25,9 +25,9 @@ VOID _app_loginit (BOOLEAN is_install)
|
||||
if (!is_install || !app.ConfigGetBoolean (L"IsLogEnabled", FALSE))
|
||||
return; // already closed or not enabled
|
||||
|
||||
rstring path = _r_path_expand (app.ConfigGetString (L"LogPath", LOG_PATH_DEFAULT));
|
||||
rstring path = _r_path_expand (app.ConfigGetString (L"LogPath", LOG_PATH_DEFAULT).GetString ());
|
||||
|
||||
config.hlogfile = CreateFile (path, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
config.hlogfile = CreateFile (path.GetString (), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
if (!_r_fs_isvalidhandle (config.hlogfile))
|
||||
return;
|
||||
@@ -91,10 +91,10 @@ VOID _app_logwrite (PITEM_LOG ptr_log)
|
||||
ptr_log->local_port ? _app_formatport (ptr_log->local_port, TRUE).GetString () : SZ_EMPTY,
|
||||
!_r_str_isempty (remote_fmt) ? remote_fmt : SZ_EMPTY,
|
||||
ptr_log->remote_port ? _app_formatport (ptr_log->remote_port, TRUE).GetString () : SZ_EMPTY,
|
||||
_app_getprotoname (ptr_log->protocol, ptr_log->af).GetString (),
|
||||
_app_getprotoname (ptr_log->protocol, ptr_log->af, SZ_UNKNOWN).GetString (),
|
||||
_app_getfiltername (ptr_log->provider_name, ptr_log->filter_name, SZ_EMPTY).GetString (),
|
||||
ptr_log->filter_id,
|
||||
_app_getdirectionname (ptr_log->direction, ptr_log->is_loopback).GetString (),
|
||||
_app_getdirectionname (ptr_log->direction, ptr_log->is_loopback, FALSE).GetString (),
|
||||
(ptr_log->is_allow ? SZ_STATE_ALLOW : SZ_STATE_BLOCK)
|
||||
);
|
||||
|
||||
@@ -199,16 +199,16 @@ VOID _app_logwrite_ui (HWND hwnd, PITEM_LOG ptr_log)
|
||||
_r_listview_additem (hwnd, log_listview_id, item_id, 0, !_r_str_isempty (display_name) ? display_name : SZ_EMPTY, icon_id, I_GROUPIDNONE, index);
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 1, !_r_str_isempty (local_fmt) ? local_fmt : SZ_EMPTY);
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 3, !_r_str_isempty (remote_fmt) ? remote_fmt : SZ_EMPTY);
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 5, _app_getprotoname (ptr_log->protocol, ptr_log->af));
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 5, _app_getprotoname (ptr_log->protocol, ptr_log->af, NULL).GetString ());
|
||||
|
||||
if (ptr_log->local_port)
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 2, _app_formatport (ptr_log->local_port, TRUE));
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 2, _app_formatport (ptr_log->local_port, TRUE).GetString ());
|
||||
|
||||
if (ptr_log->remote_port)
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 4, _app_formatport (ptr_log->remote_port, TRUE));
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 4, _app_formatport (ptr_log->remote_port, TRUE).GetString ());
|
||||
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 6, _app_getfiltername (NULL, ptr_log->filter_name, SZ_EMPTY));
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 7, _app_getdirectionname (ptr_log->direction, ptr_log->is_loopback));
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 6, _app_getfiltername (NULL, ptr_log->filter_name, SZ_EMPTY).GetString ());
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 7, _app_getdirectionname (ptr_log->direction, ptr_log->is_loopback, FALSE).GetString ());
|
||||
_r_listview_setitem (hwnd, log_listview_id, item_id, 8, ptr_log->is_allow ? SZ_STATE_ALLOW : SZ_STATE_BLOCK);
|
||||
|
||||
SAFE_DELETE_MEMORY (local_fmt);
|
||||
@@ -228,7 +228,7 @@ BOOLEAN _app_logislimitreached ()
|
||||
if (!limit || !_r_fs_isvalidhandle (config.hlogfile))
|
||||
return FALSE;
|
||||
|
||||
return (_r_fs_size (config.hlogfile) >= (limit * _R_BYTESIZE_KB));
|
||||
return (_r_fs_size (config.hlogfile) >= (_r_calc_kilobytes2bytes (LONG64, limit)));
|
||||
}
|
||||
|
||||
VOID _app_logclear ()
|
||||
@@ -243,10 +243,10 @@ VOID _app_logclear ()
|
||||
}
|
||||
else
|
||||
{
|
||||
rstring path = _r_path_expand (app.ConfigGetString (L"LogPath", LOG_PATH_DEFAULT));
|
||||
rstring path = _r_path_expand (app.ConfigGetString (L"LogPath", LOG_PATH_DEFAULT).GetString ());
|
||||
|
||||
_r_fs_remove (path, _R_FLAG_REMOVE_FORCE);
|
||||
_r_fs_remove (_r_fmt (L"%s.bak", path.GetString ()), _R_FLAG_REMOVE_FORCE);
|
||||
_r_fs_remove (path.GetString (), _R_FLAG_REMOVE_FORCE);
|
||||
_r_fs_remove (_r_fmt (L"%s.bak", path.GetString ()).GetString (), _R_FLAG_REMOVE_FORCE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ VOID CALLBACK _wfp_logcallback (UINT32 flags, FILETIME const* pft, UINT8 const*
|
||||
{
|
||||
if (RtlEqualMemory (&layer->layerKey, &FWPM_LAYER_ALE_FLOW_ESTABLISHED_V4, sizeof (GUID)) || RtlEqualMemory (&layer->layerKey, &FWPM_LAYER_ALE_FLOW_ESTABLISHED_V6, sizeof (GUID)))
|
||||
{
|
||||
FwpmFreeMemory ((LPVOID*)&layer);
|
||||
FwpmFreeMemory ((PVOID*)&layer);
|
||||
return;
|
||||
}
|
||||
else if (RtlEqualMemory (&layer->layerKey, &FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4, sizeof (GUID)) || RtlEqualMemory (&layer->layerKey, &FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6, sizeof (GUID)))
|
||||
@@ -383,7 +383,7 @@ VOID CALLBACK _wfp_logcallback (UINT32 flags, FILETIME const* pft, UINT8 const*
|
||||
direction = FWP_DIRECTION_INBOUND; // HACK!!! (issue #581)
|
||||
}
|
||||
|
||||
FwpmFreeMemory ((LPVOID*)&layer);
|
||||
FwpmFreeMemory ((PVOID*)&layer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,10 +417,10 @@ VOID CALLBACK _wfp_logcallback (UINT32 flags, FILETIME const* pft, UINT8 const*
|
||||
}
|
||||
|
||||
if (ptr_filter)
|
||||
FwpmFreeMemory ((LPVOID*)&ptr_filter);
|
||||
FwpmFreeMemory ((PVOID*)&ptr_filter);
|
||||
|
||||
if (ptr_provider)
|
||||
FwpmFreeMemory ((LPVOID*)&ptr_provider);
|
||||
FwpmFreeMemory ((PVOID*)&ptr_provider);
|
||||
|
||||
// prevent filter "not found" items
|
||||
if (filter_name.IsEmpty () && provider_name.IsEmpty ())
|
||||
@@ -441,15 +441,15 @@ VOID CALLBACK _wfp_logcallback (UINT32 flags, FILETIME const* pft, UINT8 const*
|
||||
{
|
||||
sidstring = _r_str_fromsid (package_id);
|
||||
|
||||
if (sidstring.IsEmpty () || !_app_item_get (DataAppUWP, _r_str_hash (sidstring), NULL, NULL, NULL, NULL))
|
||||
if (sidstring.IsEmpty () || !_app_item_get (DataAppUWP, _r_str_hash (sidstring.GetString ()), NULL, NULL, NULL, NULL))
|
||||
sidstring.Release ();
|
||||
}
|
||||
|
||||
// copy converted nt device path into win32
|
||||
if ((flags & FWPM_NET_EVENT_FLAG_PACKAGE_ID_SET) != 0 && !sidstring.IsEmpty ())
|
||||
{
|
||||
_r_str_alloc (&ptr_log->path, sidstring.GetLength (), sidstring);
|
||||
ptr_log->app_hash = _r_str_hash (sidstring);
|
||||
_r_str_alloc (&ptr_log->path, sidstring.GetLength (), sidstring.GetString ());
|
||||
ptr_log->app_hash = _r_str_hash (sidstring.GetString ());
|
||||
}
|
||||
else if ((flags & FWPM_NET_EVENT_FLAG_APP_ID_SET) != 0 && app_id)
|
||||
{
|
||||
@@ -457,8 +457,8 @@ VOID CALLBACK _wfp_logcallback (UINT32 flags, FILETIME const* pft, UINT8 const*
|
||||
|
||||
if (!path.IsEmpty ())
|
||||
{
|
||||
_r_str_alloc (&ptr_log->path, path.GetLength (), path);
|
||||
ptr_log->app_hash = _r_str_hash (path);
|
||||
_r_str_alloc (&ptr_log->path, path.GetLength (), path.GetString ());
|
||||
ptr_log->app_hash = _r_str_hash (path.GetString ());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -476,7 +476,7 @@ VOID CALLBACK _wfp_logcallback (UINT32 flags, FILETIME const* pft, UINT8 const*
|
||||
rstring userstring = _r_sys_getusernamefromsid (user_id);
|
||||
|
||||
if (!userstring.IsEmpty ())
|
||||
_r_str_alloc (&ptr_log->username, userstring.GetLength (), userstring);
|
||||
_r_str_alloc (&ptr_log->username, userstring.GetLength (), userstring.GetString ());
|
||||
}
|
||||
|
||||
// indicates the direction of the packet transmission
|
||||
@@ -547,8 +547,8 @@ VOID CALLBACK _wfp_logcallback (UINT32 flags, FILETIME const* pft, UINT8 const*
|
||||
|
||||
ptr_log->is_myprovider = is_myprovider;
|
||||
|
||||
_r_str_alloc (&ptr_log->filter_name, filter_name.GetLength (), filter_name);
|
||||
_r_str_alloc (&ptr_log->provider_name, provider_name.GetLength (), provider_name);
|
||||
_r_str_alloc (&ptr_log->filter_name, filter_name.GetLength (), filter_name.GetString ());
|
||||
_r_str_alloc (&ptr_log->provider_name, provider_name.GetLength (), provider_name.GetString ());
|
||||
|
||||
ptr_log->is_blocklist = (filter_weight == FILTER_WEIGHT_BLOCKLIST);
|
||||
ptr_log->is_system = (filter_weight == FILTER_WEIGHT_HIGHEST) || (filter_weight == FILTER_WEIGHT_HIGHEST_IMPORTANT);
|
||||
@@ -583,7 +583,7 @@ VOID CALLBACK _wfp_logcallback (UINT32 flags, FILETIME const* pft, UINT8 const*
|
||||
}
|
||||
|
||||
// win7+ callback
|
||||
VOID CALLBACK _wfp_logcallback0 (LPVOID pContext, const FWPM_NET_EVENT1* pEvent)
|
||||
VOID CALLBACK _wfp_logcallback0 (PVOID pContext, const FWPM_NET_EVENT1* pEvent)
|
||||
{
|
||||
UINT16 layer_id;
|
||||
UINT64 filter_id;
|
||||
@@ -613,7 +613,7 @@ VOID CALLBACK _wfp_logcallback0 (LPVOID pContext, const FWPM_NET_EVENT1* pEvent)
|
||||
}
|
||||
|
||||
// win8+ callback
|
||||
VOID CALLBACK _wfp_logcallback1 (LPVOID pContext, const FWPM_NET_EVENT2* pEvent)
|
||||
VOID CALLBACK _wfp_logcallback1 (PVOID pContext, const FWPM_NET_EVENT2* pEvent)
|
||||
{
|
||||
UINT16 layer_id;
|
||||
UINT64 filter_id;
|
||||
@@ -661,7 +661,7 @@ VOID CALLBACK _wfp_logcallback1 (LPVOID pContext, const FWPM_NET_EVENT2* pEvent)
|
||||
}
|
||||
|
||||
// win10rs1+ callback
|
||||
VOID CALLBACK _wfp_logcallback2 (LPVOID pContext, const FWPM_NET_EVENT3* pEvent)
|
||||
VOID CALLBACK _wfp_logcallback2 (PVOID pContext, const FWPM_NET_EVENT3* pEvent)
|
||||
{
|
||||
UINT16 layer_id;
|
||||
UINT64 filter_id;
|
||||
@@ -709,7 +709,7 @@ VOID CALLBACK _wfp_logcallback2 (LPVOID pContext, const FWPM_NET_EVENT3* pEvent)
|
||||
}
|
||||
|
||||
// win10rs4+ callback
|
||||
VOID CALLBACK _wfp_logcallback3 (LPVOID pContext, const FWPM_NET_EVENT4* pEvent)
|
||||
VOID CALLBACK _wfp_logcallback3 (PVOID pContext, const FWPM_NET_EVENT4* pEvent)
|
||||
{
|
||||
UINT16 layer_id;
|
||||
UINT64 filter_id;
|
||||
@@ -757,7 +757,7 @@ VOID CALLBACK _wfp_logcallback3 (LPVOID pContext, const FWPM_NET_EVENT4* pEvent)
|
||||
}
|
||||
|
||||
// win10rs5+ callback
|
||||
VOID CALLBACK _wfp_logcallback4 (LPVOID pContext, const FWPM_NET_EVENT5* pEvent)
|
||||
VOID CALLBACK _wfp_logcallback4 (PVOID pContext, const FWPM_NET_EVENT5* pEvent)
|
||||
{
|
||||
UINT16 layer_id;
|
||||
UINT64 filter_id;
|
||||
@@ -804,7 +804,7 @@ VOID CALLBACK _wfp_logcallback4 (LPVOID pContext, const FWPM_NET_EVENT5* pEvent)
|
||||
_wfp_logcallback (pEvent->header.flags, &pEvent->header.timeStamp, pEvent->header.appId.data, pEvent->header.packageSid, pEvent->header.userId, pEvent->header.ipProtocol, pEvent->header.ipVersion, pEvent->header.remoteAddrV4, &pEvent->header.remoteAddrV6, pEvent->header.remotePort, pEvent->header.localAddrV4, &pEvent->header.localAddrV6, pEvent->header.localPort, layer_id, filter_id, direction, is_allow, is_loopback);
|
||||
}
|
||||
|
||||
THREAD_FN LogThread (LPVOID lparam)
|
||||
THREAD_FN LogThread (PVOID lparam)
|
||||
{
|
||||
HWND hwnd = (HWND)lparam;
|
||||
|
||||
|
||||
+6
-6
@@ -18,10 +18,10 @@ VOID _wfp_logunsubscribe (HANDLE hengine);
|
||||
|
||||
VOID CALLBACK _wfp_logcallback (UINT32 flags, FILETIME const* pft, UINT8 const* app_id, SID* package_id, SID* user_id, UINT8 proto, FWP_IP_VERSION ipver, UINT32 remote_addr4, FWP_BYTE_ARRAY16 const* remote_addr6, UINT16 remote_port, UINT32 local_addr4, FWP_BYTE_ARRAY16 const* local_addr6, UINT16 local_port, UINT16 layer_id, UINT64 filter_id, UINT32 direction, BOOLEAN is_allow, BOOLEAN is_loopback);
|
||||
|
||||
VOID CALLBACK _wfp_logcallback0 (LPVOID pContext, const FWPM_NET_EVENT1* pEvent);
|
||||
VOID CALLBACK _wfp_logcallback1 (LPVOID pContext, const FWPM_NET_EVENT2* pEvent);
|
||||
VOID CALLBACK _wfp_logcallback2 (LPVOID pContext, const FWPM_NET_EVENT3* pEvent);
|
||||
VOID CALLBACK _wfp_logcallback3 (LPVOID pContext, const FWPM_NET_EVENT4* pEvent);
|
||||
VOID CALLBACK _wfp_logcallback4 (LPVOID pContext, const FWPM_NET_EVENT5* pEvent);
|
||||
VOID CALLBACK _wfp_logcallback0 (PVOID pContext, const FWPM_NET_EVENT1* pEvent);
|
||||
VOID CALLBACK _wfp_logcallback1 (PVOID pContext, const FWPM_NET_EVENT2* pEvent);
|
||||
VOID CALLBACK _wfp_logcallback2 (PVOID pContext, const FWPM_NET_EVENT3* pEvent);
|
||||
VOID CALLBACK _wfp_logcallback3 (PVOID pContext, const FWPM_NET_EVENT4* pEvent);
|
||||
VOID CALLBACK _wfp_logcallback4 (PVOID pContext, const FWPM_NET_EVENT5* pEvent);
|
||||
|
||||
THREAD_FN LogThread (LPVOID lparam);
|
||||
THREAD_FN LogThread (PVOID lparam);
|
||||
+260
-261
File diff suppressed because it is too large.
Load diff
+3
-3
@@ -95,7 +95,7 @@ typedef enum _ENUM_INSTALL_TYPE
|
||||
#define LOG_PATH_EXT L"log"
|
||||
#define LOG_PATH_DEFAULT L"%USERPROFILE%\\" APP_NAME_SHORT L"." LOG_PATH_EXT
|
||||
#define LOG_VIEWER_DEFAULT L"%SystemRoot%\\notepad.exe"
|
||||
#define LOG_SIZE_LIMIT_DEFAULT _R_BYTESIZE_KB
|
||||
#define LOG_SIZE_LIMIT_DEFAULT _r_calc_kilobytes2bytes (DWORD, 1)
|
||||
|
||||
#define PROC_SYSTEM_PID 4
|
||||
#define PROC_SYSTEM_NAME L"System"
|
||||
@@ -136,7 +136,7 @@ typedef enum _ENUM_INSTALL_TYPE
|
||||
#define SZ_DIRECTION_IN L"Inbound"
|
||||
#define SZ_DIRECTION_OUT L"Outbound"
|
||||
#define SZ_DIRECTION_ANY L"Any"
|
||||
#define SZ_DIRECTION_LOOPBACK L"-Loopback"
|
||||
#define SZ_DIRECTION_LOOPBACK L"Loopback"
|
||||
|
||||
#define SZ_LOG_TITLE L"Date" DIVIDER_CSV L"User" DIVIDER_CSV L"Path" DIVIDER_CSV L"Address (" SZ_DIRECTION_LOCAL L")" DIVIDER_CSV L"Port (" SZ_DIRECTION_LOCAL L")" DIVIDER_CSV L"Address (" SZ_DIRECTION_REMOTE L")" DIVIDER_CSV L"Port (" SZ_DIRECTION_REMOTE L")" DIVIDER_CSV L"Protocol" DIVIDER_CSV L"Filter name" DIVIDER_CSV L"Filter ID" DIVIDER_CSV L"Direction" DIVIDER_CSV L"State\r\n"
|
||||
#define SZ_LOG_BODY L"\"%s\"" DIVIDER_CSV L"\"%s\"" DIVIDER_CSV L"\"%s\"" DIVIDER_CSV L"\"%s\"" DIVIDER_CSV L"\"%s\"" DIVIDER_CSV L"\"%s\"" DIVIDER_CSV L"\"%s\"" DIVIDER_CSV L"\"%s\"" DIVIDER_CSV L"\"%s\"" DIVIDER_CSV L"\"#%" TEXT (PRIu64) L"\"" DIVIDER_CSV L"\"%s\"" DIVIDER_CSV L"\"%s\"\r\n"
|
||||
@@ -144,7 +144,7 @@ typedef enum _ENUM_INSTALL_TYPE
|
||||
#define UI_FONT L"Segoe UI"
|
||||
#define UI_FONT_NOTIFICATION L"Calibri"
|
||||
#define UI_FONT_DEFAULT UI_FONT L";9;400"
|
||||
#define BACKUP_HOURS_PERIOD 4 // make backup every X hour(s) (default)
|
||||
#define BACKUP_HOURS_PERIOD _r_calc_hours2seconds (time_t, 4) // make backup every X hour(s) (default)
|
||||
|
||||
#define LEN_IP_MAX 68
|
||||
#define MAP_CACHE_MAX 1024
|
||||
|
||||
+92
-85
@@ -244,32 +244,30 @@ BOOLEAN _app_notifyshow (HWND hwnd, PITEM_LOG ptr_log, BOOLEAN is_forced, BOOLEA
|
||||
}
|
||||
}
|
||||
|
||||
SetWindowText (hwnd, _r_fmt (L"%s - " APP_NAME, app.LocaleString (IDS_NOTIFY_TITLE, NULL).GetString ()));
|
||||
SetWindowText (hwnd, _r_fmt (L"%s - " APP_NAME, app.LocaleString (IDS_NOTIFY_TITLE, NULL).GetString ()).GetString ());
|
||||
|
||||
SetWindowLongPtr (hwnd, GWLP_USERDATA, (LONG_PTR)ptr_log->app_hash);
|
||||
SetWindowLongPtr (GetDlgItem (hwnd, IDC_HEADER_ID), GWLP_USERDATA, (LONG_PTR)ptr_log->hicon);
|
||||
|
||||
// print table text
|
||||
{
|
||||
BOOLEAN is_inbound = (ptr_log->direction == FWP_DIRECTION_INBOUND);
|
||||
|
||||
LPWSTR remote_fmt = NULL;
|
||||
_app_formataddress (ptr_log->af, 0, &ptr_log->remote_addr, 0, &remote_fmt, FMTADDR_RESOLVE_HOST);
|
||||
|
||||
_r_ctrl_settabletext (hwnd, IDC_FILE_ID, app.LocaleString (IDS_NAME, L":"), IDC_FILE_TEXT, !_r_str_isempty (ptr_app->display_name) ? _r_path_getfilename (ptr_app->display_name) : empty_text);
|
||||
_r_ctrl_settabletext (hwnd, IDC_SIGNATURE_ID, app.LocaleString (IDS_SIGNATURE, L":"), IDC_SIGNATURE_TEXT, is_signed.IsEmpty () ? empty_text : is_signed);
|
||||
_r_ctrl_settabletext (hwnd, IDC_ADDRESS_ID, app.LocaleString (IDS_ADDRESS, L":"), IDC_ADDRESS_TEXT, !_r_str_isempty (remote_fmt) ? remote_fmt : empty_text);
|
||||
_r_ctrl_settabletext (hwnd, IDC_PORT_ID, app.LocaleString (IDS_PORT, L":"), IDC_PORT_TEXT, ptr_log->remote_port ? _app_formatport (ptr_log->remote_port, FALSE).GetString () : empty_text);
|
||||
_r_ctrl_settabletext (hwnd, IDC_DIRECTION_ID, app.LocaleString (IDS_DIRECTION, L":"), IDC_DIRECTION_TEXT, app.LocaleString (is_inbound ? IDS_DIRECTION_2 : IDS_DIRECTION_1, ptr_log->is_loopback ? L" (Loopback)" : NULL));
|
||||
_r_ctrl_settabletext (hwnd, IDC_FILTER_ID, app.LocaleString (IDS_FILTER, L":"), IDC_FILTER_TEXT, !_r_str_isempty (ptr_log->filter_name) ? ptr_log->filter_name : empty_text);
|
||||
_r_ctrl_settabletext (hwnd, IDC_DATE_ID, app.LocaleString (IDS_DATE, L":"), IDC_DATE_TEXT, _r_fmt_dateex (ptr_log->timestamp, FDTF_SHORTDATE | FDTF_LONGTIME));
|
||||
_r_ctrl_settabletext (hwnd, IDC_FILE_ID, app.LocaleString (IDS_NAME, L":").GetString (), IDC_FILE_TEXT, !_r_str_isempty (ptr_app->display_name) ? _r_path_getfilename (ptr_app->display_name) : empty_text.GetString ());
|
||||
_r_ctrl_settabletext (hwnd, IDC_SIGNATURE_ID, app.LocaleString (IDS_SIGNATURE, L":").GetString (), IDC_SIGNATURE_TEXT, is_signed.IsEmpty () ? empty_text.GetString () : is_signed.GetString ());
|
||||
_r_ctrl_settabletext (hwnd, IDC_ADDRESS_ID, app.LocaleString (IDS_ADDRESS, L":").GetString (), IDC_ADDRESS_TEXT, !_r_str_isempty (remote_fmt) ? remote_fmt : empty_text.GetString ());
|
||||
_r_ctrl_settabletext (hwnd, IDC_PORT_ID, app.LocaleString (IDS_PORT, L":").GetString (), IDC_PORT_TEXT, ptr_log->remote_port ? _app_formatport (ptr_log->remote_port, FALSE).GetString () : empty_text.GetString ());
|
||||
_r_ctrl_settabletext (hwnd, IDC_DIRECTION_ID, app.LocaleString (IDS_DIRECTION, L":").GetString (), IDC_DIRECTION_TEXT, _app_getdirectionname (ptr_log->direction, ptr_log->is_loopback, TRUE).GetString ());
|
||||
_r_ctrl_settabletext (hwnd, IDC_FILTER_ID, app.LocaleString (IDS_FILTER, L":").GetString (), IDC_FILTER_TEXT, !_r_str_isempty (ptr_log->filter_name) ? ptr_log->filter_name : empty_text.GetString ());
|
||||
_r_ctrl_settabletext (hwnd, IDC_DATE_ID, app.LocaleString (IDS_DATE, L":").GetString (), IDC_DATE_TEXT, _r_fmt_dateex (ptr_log->timestamp, FDTF_SHORTDATE | FDTF_LONGTIME).GetString ());
|
||||
|
||||
SAFE_DELETE_MEMORY (remote_fmt);
|
||||
}
|
||||
|
||||
_r_ctrl_settext (hwnd, IDC_RULES_BTN, app.LocaleString (IDS_TRAY_RULES, NULL));
|
||||
_r_ctrl_settext (hwnd, IDC_ALLOW_BTN, app.LocaleString (IDS_ACTION_ALLOW, NULL));
|
||||
_r_ctrl_settext (hwnd, IDC_BLOCK_BTN, app.LocaleString (IDS_ACTION_BLOCK, NULL));
|
||||
_r_ctrl_settext (hwnd, IDC_RULES_BTN, app.LocaleString (IDS_TRAY_RULES, NULL).GetString ());
|
||||
_r_ctrl_settext (hwnd, IDC_ALLOW_BTN, app.LocaleString (IDS_ACTION_ALLOW, NULL).GetString ());
|
||||
_r_ctrl_settext (hwnd, IDC_BLOCK_BTN, app.LocaleString (IDS_ACTION_BLOCK, NULL).GetString ());
|
||||
|
||||
_r_ctrl_enable (hwnd, IDC_RULES_BTN, !is_safety);
|
||||
_r_ctrl_enable (hwnd, IDC_ALLOW_BTN, !is_safety);
|
||||
@@ -325,11 +323,11 @@ VOID _app_notifyplaysound ()
|
||||
|
||||
if (!path.IsEmpty ())
|
||||
{
|
||||
path = _r_path_expand (path);
|
||||
path = _r_path_expand (path.GetString ());
|
||||
|
||||
if (_r_fs_exists (path))
|
||||
if (_r_fs_exists (path.GetString ()))
|
||||
{
|
||||
_r_str_copy (notify_snd_path, RTL_NUMBER_OF (notify_snd_path), path);
|
||||
_r_str_copy (notify_snd_path, RTL_NUMBER_OF (notify_snd_path), path.GetString ());
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -371,56 +369,61 @@ VOID _app_notifysetpos (HWND hwnd, BOOLEAN is_forced)
|
||||
{
|
||||
if (!is_forced && IsWindowVisible (hwnd))
|
||||
{
|
||||
RECT windowRect = {0};
|
||||
GetWindowRect (hwnd, &windowRect);
|
||||
RECT windowRect;
|
||||
|
||||
_r_wnd_adjustwindowrect (hwnd, &windowRect);
|
||||
SetWindowPos (hwnd, NULL, windowRect.left, windowRect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
|
||||
if (GetWindowRect (hwnd, &windowRect))
|
||||
{
|
||||
_r_wnd_adjustwindowrect (hwnd, &windowRect);
|
||||
SetWindowPos (hwnd, NULL, windowRect.left, windowRect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN is_intray = app.ConfigGetBoolean (L"IsNotificationsOnTray", FALSE);
|
||||
|
||||
if (is_intray)
|
||||
{
|
||||
RECT windowRect = {0};
|
||||
GetWindowRect (hwnd, &windowRect);
|
||||
RECT windowRect;
|
||||
|
||||
RECT desktopRect = {0};
|
||||
SystemParametersInfo (SPI_GETWORKAREA, 0, &desktopRect, 0);
|
||||
|
||||
APPBARDATA abd = {0};
|
||||
|
||||
abd.cbSize = sizeof (abd);
|
||||
|
||||
if (SHAppBarMessage (ABM_GETTASKBARPOS, &abd))
|
||||
if (GetWindowRect (hwnd, &windowRect))
|
||||
{
|
||||
INT border_x = _r_dc_getsystemmetrics (hwnd, SM_CXBORDER);
|
||||
RECT desktopRect;
|
||||
|
||||
if (abd.uEdge == ABE_LEFT)
|
||||
if (SystemParametersInfo (SPI_GETWORKAREA, 0, &desktopRect, 0))
|
||||
{
|
||||
windowRect.left = abd.rc.right + border_x;
|
||||
windowRect.top = (desktopRect.bottom - _r_calc_rectheight (LONG, &windowRect)) - border_x;
|
||||
}
|
||||
else if (abd.uEdge == ABE_TOP)
|
||||
{
|
||||
windowRect.left = (desktopRect.right - _r_calc_rectwidth (LONG, &windowRect)) - border_x;
|
||||
windowRect.top = abd.rc.bottom + border_x;
|
||||
}
|
||||
else if (abd.uEdge == ABE_RIGHT)
|
||||
{
|
||||
windowRect.left = (desktopRect.right - _r_calc_rectwidth (LONG, &windowRect)) - border_x;
|
||||
windowRect.top = (desktopRect.bottom - _r_calc_rectheight (LONG, &windowRect)) - border_x;
|
||||
}
|
||||
else/* if (abd.uEdge == ABE_BOTTOM)*/
|
||||
{
|
||||
windowRect.left = (desktopRect.right - (windowRect.right - windowRect.left)) - border_x;
|
||||
windowRect.top = (desktopRect.bottom - _r_calc_rectheight (LONG, &windowRect)) - border_x;
|
||||
}
|
||||
APPBARDATA abd;
|
||||
abd.cbSize = sizeof (abd);
|
||||
|
||||
SetWindowPos (hwnd, NULL, windowRect.left, windowRect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
|
||||
return;
|
||||
if ((BOOL)SHAppBarMessage (ABM_GETTASKBARPOS, &abd))
|
||||
{
|
||||
INT border_x = _r_dc_getsystemmetrics (hwnd, SM_CXBORDER);
|
||||
|
||||
if (abd.uEdge == ABE_LEFT)
|
||||
{
|
||||
windowRect.left = abd.rc.right + border_x;
|
||||
windowRect.top = (desktopRect.bottom - _r_calc_rectheight (LONG, &windowRect)) - border_x;
|
||||
}
|
||||
else if (abd.uEdge == ABE_TOP)
|
||||
{
|
||||
windowRect.left = (desktopRect.right - _r_calc_rectwidth (LONG, &windowRect)) - border_x;
|
||||
windowRect.top = abd.rc.bottom + border_x;
|
||||
}
|
||||
else if (abd.uEdge == ABE_RIGHT)
|
||||
{
|
||||
windowRect.left = (desktopRect.right - _r_calc_rectwidth (LONG, &windowRect)) - border_x;
|
||||
windowRect.top = (desktopRect.bottom - _r_calc_rectheight (LONG, &windowRect)) - border_x;
|
||||
}
|
||||
else/* if (abd.uEdge == ABE_BOTTOM)*/
|
||||
{
|
||||
windowRect.left = (desktopRect.right - (windowRect.right - windowRect.left)) - border_x;
|
||||
windowRect.top = (desktopRect.bottom - _r_calc_rectheight (LONG, &windowRect)) - border_x;
|
||||
}
|
||||
|
||||
SetWindowPos (hwnd, NULL, windowRect.left, windowRect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,10 +606,10 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
{
|
||||
RECT rc = {0};
|
||||
GetClientRect (hwnd, &rc);
|
||||
RECT clientRect;
|
||||
|
||||
_r_dc_fillrect ((HDC)wparam, &rc, GetSysColor (COLOR_WINDOW));
|
||||
if (GetClientRect (hwnd, &clientRect))
|
||||
_r_dc_fillrect ((HDC)wparam, &clientRect, GetSysColor (COLOR_WINDOW));
|
||||
|
||||
SetWindowLongPtr (hwnd, DWLP_MSGRESULT, TRUE);
|
||||
return TRUE;
|
||||
@@ -619,17 +622,19 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
|
||||
if (hdc)
|
||||
{
|
||||
RECT rc = {0};
|
||||
GetClientRect (hwnd, &rc);
|
||||
RECT clientRect;
|
||||
|
||||
INT wnd_width = _r_calc_rectwidth (INT, &rc);
|
||||
INT wnd_height = _r_calc_rectheight (INT, &rc);
|
||||
if (GetClientRect (hwnd, &clientRect))
|
||||
{
|
||||
INT wnd_width = _r_calc_rectwidth (INT, &clientRect);
|
||||
INT wnd_height = _r_calc_rectheight (INT, &clientRect);
|
||||
|
||||
SetRect (&rc, 0, wnd_height - _r_dc_getdpi (hwnd, _R_SIZE_FOOTERHEIGHT), wnd_width, wnd_height);
|
||||
_r_dc_fillrect (hdc, &rc, GetSysColor (COLOR_3DFACE));
|
||||
SetRect (&clientRect, 0, wnd_height - _r_dc_getdpi (hwnd, _R_SIZE_FOOTERHEIGHT), wnd_width, wnd_height);
|
||||
_r_dc_fillrect (hdc, &clientRect, GetSysColor (COLOR_3DFACE));
|
||||
|
||||
for (INT i = 0; i < wnd_width; i++)
|
||||
SetPixelV (hdc, i, rc.top, GetSysColor (COLOR_APPWORKSPACE));
|
||||
for (INT i = 0; i < wnd_width; i++)
|
||||
SetPixelV (hdc, i, clientRect.top, GetSysColor (COLOR_APPWORKSPACE));
|
||||
}
|
||||
|
||||
EndPaint (hwnd, &ps);
|
||||
}
|
||||
@@ -668,11 +673,11 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
INT wnd_icon_size = _r_dc_getsystemmetrics (hwnd, SM_CXICON);
|
||||
INT wnd_spacing = _r_dc_getdpi (hwnd, 12);
|
||||
|
||||
RECT rcText = {0};
|
||||
RECT rcIcon = {0};
|
||||
RECT textRect;
|
||||
RECT iconRect;
|
||||
|
||||
SetRect (&rcText, wnd_spacing, 0, _r_calc_rectwidth (INT, &drawInfo->rcItem) - (wnd_spacing * 3) - wnd_icon_size, _r_calc_rectheight (INT, &drawInfo->rcItem));
|
||||
SetRect (&rcIcon, _r_calc_rectwidth (INT, &drawInfo->rcItem) - wnd_icon_size - wnd_spacing, (_r_calc_rectheight (INT, &drawInfo->rcItem) / 2) - (wnd_icon_size / 2), wnd_icon_size, wnd_icon_size);
|
||||
SetRect (&textRect, wnd_spacing, 0, _r_calc_rectwidth (INT, &drawInfo->rcItem) - (wnd_spacing * 3) - wnd_icon_size, _r_calc_rectheight (INT, &drawInfo->rcItem));
|
||||
SetRect (&iconRect, _r_calc_rectwidth (INT, &drawInfo->rcItem) - wnd_icon_size - wnd_spacing, (_r_calc_rectheight (INT, &drawInfo->rcItem) / 2) - (wnd_icon_size / 2), wnd_icon_size, wnd_icon_size);
|
||||
|
||||
SetBkMode (drawInfo->hDC, TRANSPARENT);
|
||||
|
||||
@@ -681,10 +686,10 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
|
||||
// draw title text
|
||||
WCHAR text[128] = {0};
|
||||
_r_str_printf (text, RTL_NUMBER_OF (text), app.LocaleString (IDS_NOTIFY_HEADER, NULL), APP_NAME);
|
||||
_r_str_printf (text, RTL_NUMBER_OF (text), app.LocaleString (IDS_NOTIFY_HEADER, NULL).GetString (), APP_NAME);
|
||||
|
||||
COLORREF clr_prev = SetTextColor (drawInfo->hDC, GetSysColor (COLOR_WINDOW));
|
||||
DrawTextEx (drawInfo->hDC, text, (INT)_r_str_length (text), &rcText, DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOCLIP | DT_NOPREFIX, NULL);
|
||||
DrawTextEx (drawInfo->hDC, text, (INT)_r_str_length (text), &textRect, DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOCLIP | DT_NOPREFIX, NULL);
|
||||
SetTextColor (drawInfo->hDC, clr_prev);
|
||||
|
||||
// draw icon
|
||||
@@ -694,7 +699,7 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
hicon = config.hicon_large;
|
||||
|
||||
if (hicon)
|
||||
DrawIconEx (drawInfo->hDC, rcIcon.left, rcIcon.top, hicon, rcIcon.right, rcIcon.bottom, 0, NULL, DI_IMAGE | DI_MASK);
|
||||
DrawIconEx (drawInfo->hDC, iconRect.left, iconRect.top, hicon, iconRect.right, iconRect.bottom, 0, NULL, DI_IMAGE | DI_MASK);
|
||||
|
||||
SetWindowLongPtr (hwnd, DWLP_MSGRESULT, TRUE);
|
||||
return TRUE;
|
||||
@@ -744,7 +749,7 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
{
|
||||
case BCN_DROPDOWN:
|
||||
{
|
||||
INT ctrl_id = PtrToInt ((LPVOID)nmlp->idFrom);
|
||||
INT ctrl_id = PtrToInt ((PVOID)nmlp->idFrom);
|
||||
|
||||
if (!_r_ctrl_isenabled (hwnd, ctrl_id) || (ctrl_id != IDC_RULES_BTN && ctrl_id != IDC_ALLOW_BTN))
|
||||
break;
|
||||
@@ -756,13 +761,13 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
|
||||
if (ctrl_id == IDC_RULES_BTN)
|
||||
{
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_DISABLENOTIFICATIONS, app.LocaleString (IDS_DISABLENOTIFICATIONS, NULL));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDM_DISABLENOTIFICATIONS, app.LocaleString (IDS_DISABLENOTIFICATIONS, NULL).GetString ());
|
||||
|
||||
_app_generate_rulesmenu (hsubmenu, _app_notifyget_id (hwnd, FALSE));
|
||||
}
|
||||
else if (ctrl_id == IDC_ALLOW_BTN)
|
||||
{
|
||||
AppendMenu (hsubmenu, MF_STRING, IDC_ALLOW_BTN, app.LocaleString (IDS_ACTION_ALLOW, NULL));
|
||||
AppendMenu (hsubmenu, MF_STRING, IDC_ALLOW_BTN, app.LocaleString (IDS_ACTION_ALLOW, NULL).GetString ());
|
||||
AppendMenu (hsubmenu, MF_SEPARATOR, 0, NULL);
|
||||
|
||||
_app_generate_timermenu (hsubmenu, 0);
|
||||
@@ -770,12 +775,14 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
_r_menu_checkitem (hsubmenu, IDC_ALLOW_BTN, IDC_ALLOW_BTN, MF_BYCOMMAND, IDC_ALLOW_BTN);
|
||||
}
|
||||
|
||||
RECT buttonRect = {0};
|
||||
RECT buttonRect;
|
||||
|
||||
GetClientRect (nmlp->hwndFrom, &buttonRect);
|
||||
ClientToScreen (nmlp->hwndFrom, (LPPOINT)&buttonRect);
|
||||
if (GetClientRect (nmlp->hwndFrom, &buttonRect))
|
||||
{
|
||||
ClientToScreen (nmlp->hwndFrom, (LPPOINT)&buttonRect);
|
||||
|
||||
_r_wnd_adjustwindowrect (nmlp->hwndFrom, &buttonRect);
|
||||
_r_wnd_adjustwindowrect (nmlp->hwndFrom, &buttonRect);
|
||||
}
|
||||
|
||||
_r_menu_popup (hsubmenu, hwnd, (LPPOINT)&buttonRect, TRUE);
|
||||
|
||||
@@ -814,7 +821,7 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
nmlvgit.iItem = item_id;
|
||||
nmlvgit.lParam = 0;
|
||||
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), _app_gettooltip (app.GetHWND (), &nmlvgit));
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), _app_gettooltip (app.GetHWND (), &nmlvgit).GetString ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -823,23 +830,23 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
}
|
||||
else if (ctrl_id == IDC_RULES_BTN)
|
||||
{
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_NOTIFY_TOOLTIP, NULL));
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_NOTIFY_TOOLTIP, NULL).GetString ());
|
||||
}
|
||||
else if (ctrl_id == IDC_ALLOW_BTN)
|
||||
{
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_ACTION_ALLOW_HINT, NULL));
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_ACTION_ALLOW_HINT, NULL).GetString ());
|
||||
}
|
||||
else if (ctrl_id == IDC_BLOCK_BTN)
|
||||
{
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_ACTION_BLOCK_HINT, NULL));
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_ACTION_BLOCK_HINT, NULL).GetString ());
|
||||
}
|
||||
else if (ctrl_id == IDC_LATER_BTN)
|
||||
{
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_ACTION_LATER_HINT, NULL));
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_ACTION_LATER_HINT, NULL).GetString ());
|
||||
}
|
||||
else
|
||||
{
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), _r_ctrl_gettext (hwnd, ctrl_id));
|
||||
_r_str_copy (buffer, RTL_NUMBER_OF (buffer), _r_ctrl_gettext (hwnd, ctrl_id).GetString ());
|
||||
}
|
||||
|
||||
if (!_r_str_isempty (buffer))
|
||||
@@ -1173,7 +1180,7 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
|
||||
if (hedit)
|
||||
{
|
||||
WCHAR class_name[64] = {0};
|
||||
WCHAR class_name[128];
|
||||
|
||||
if (GetClassName (hedit, class_name, RTL_NUMBER_OF (class_name)) > 0)
|
||||
{
|
||||
|
||||
+33
-33
@@ -87,7 +87,7 @@ SIZE_T _app_addapplication (HWND hwnd, LPCWSTR path, time_t timestamp, time_t ti
|
||||
return 0;
|
||||
|
||||
// prevent possible duplicate apps entries with short path (issue #640)
|
||||
WCHAR path_full[1024] = {0};
|
||||
WCHAR path_full[1024];
|
||||
|
||||
if (_r_str_find (path, INVALID_SIZE_T, L'~', 0) != INVALID_SIZE_T)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ SIZE_T _app_addapplication (HWND hwnd, LPCWSTR path, time_t timestamp, time_t ti
|
||||
{
|
||||
real_path = path;
|
||||
|
||||
if (!is_ntoskrnl && _r_str_find (real_path, real_path.GetLength (), OBJ_NAME_PATH_SEPARATOR, 0) == INVALID_SIZE_T)
|
||||
if (!is_ntoskrnl && _r_str_find (real_path.GetString (), real_path.GetLength (), OBJ_NAME_PATH_SEPARATOR, 0) == INVALID_SIZE_T)
|
||||
{
|
||||
if (_app_item_get (DataAppService, app_hash, NULL, &real_path, timestamp ? NULL : ×tamp, NULL))
|
||||
ptr_app->type = DataAppService;
|
||||
@@ -148,13 +148,13 @@ SIZE_T _app_addapplication (HWND hwnd, LPCWSTR path, time_t timestamp, time_t ti
|
||||
|
||||
if (!real_path.IsEmpty () && ptr_app->type == DataAppRegular)
|
||||
{
|
||||
DWORD dwAttr = GetFileAttributes (real_path);
|
||||
DWORD dwAttr = GetFileAttributes (real_path.GetString ());
|
||||
|
||||
ptr_app->is_system = is_ntoskrnl || (dwAttr & FILE_ATTRIBUTE_SYSTEM) == FILE_ATTRIBUTE_SYSTEM || (_r_str_compare_length (real_path, config.windows_dir, config.wd_length) == 0);
|
||||
ptr_app->is_system = is_ntoskrnl || (dwAttr & FILE_ATTRIBUTE_SYSTEM) == FILE_ATTRIBUTE_SYSTEM || (_r_str_compare_length (real_path.GetString (), config.windows_dir, config.wd_length) == 0);
|
||||
}
|
||||
|
||||
_r_str_alloc (&ptr_app->original_path, app_length, path);
|
||||
_r_str_alloc (&ptr_app->real_path, real_path.GetLength (), real_path);
|
||||
_r_str_alloc (&ptr_app->real_path, real_path.GetLength (), real_path.GetString ());
|
||||
|
||||
if (is_ntoskrnl && !_r_str_isempty (ptr_app->original_path))
|
||||
{
|
||||
@@ -376,7 +376,7 @@ COLORREF _app_getappcolor (INT listview_id, SIZE_T app_hash)
|
||||
if (color_value.IsEmpty ())
|
||||
return 0;
|
||||
|
||||
return _app_getcolorvalue (_r_str_hash (color_value));
|
||||
return _app_getcolorvalue (_r_str_hash (color_value.GetString ()));
|
||||
}
|
||||
|
||||
VOID _app_freeapplication (SIZE_T app_hash)
|
||||
@@ -544,14 +544,14 @@ COLORREF _app_getrulecolor (INT listview_id, SIZE_T rule_idx)
|
||||
if (color_value.IsEmpty ())
|
||||
return 0;
|
||||
|
||||
return _app_getcolorvalue (_r_str_hash (color_value));
|
||||
return _app_getcolorvalue (_r_str_hash (color_value.GetString ()));
|
||||
}
|
||||
|
||||
rstring _app_gettooltip (HWND hwnd, LPNMLVGETINFOTIP lpnmlv)
|
||||
{
|
||||
rstring result;
|
||||
|
||||
INT listview_id = PtrToInt ((LPVOID)lpnmlv->hdr.idFrom);
|
||||
INT listview_id = PtrToInt ((PVOID)lpnmlv->hdr.idFrom);
|
||||
BOOLEAN is_appslist = (listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP);
|
||||
|
||||
if (is_appslist || listview_id == IDC_RULE_APPS_ID)
|
||||
@@ -752,9 +752,9 @@ rstring _app_gettooltip (HWND hwnd, LPNMLVGETINFOTIP lpnmlv)
|
||||
app.LocaleString (IDS_ADDRESS, L" (" SZ_DIRECTION_REMOTE L")").GetString (),
|
||||
!_r_str_isempty (remote_fmt) ? remote_fmt : SZ_EMPTY,
|
||||
app.LocaleString (IDS_PROTOCOL, NULL).GetString (),
|
||||
_app_getprotoname (ptr_network->protocol, ptr_network->af).GetString (),
|
||||
_app_getprotoname (ptr_network->protocol, ptr_network->af, NULL).GetString (),
|
||||
app.LocaleString (IDS_STATE, NULL).GetString (),
|
||||
_app_getstatename (ptr_network->state, SZ_EMPTY).GetString ()
|
||||
_app_getconnectionstatusname (ptr_network->state, SZ_EMPTY).GetString ()
|
||||
);
|
||||
|
||||
SAFE_DELETE_MEMORY (local_fmt);
|
||||
@@ -786,11 +786,11 @@ rstring _app_gettooltip (HWND hwnd, LPNMLVGETINFOTIP lpnmlv)
|
||||
app.LocaleString (IDS_ADDRESS, L" (" SZ_DIRECTION_REMOTE L")").GetString (),
|
||||
!_r_str_isempty (remote_fmt) ? remote_fmt : SZ_EMPTY,
|
||||
app.LocaleString (IDS_PROTOCOL, NULL).GetString (),
|
||||
_app_getprotoname (ptr_log->protocol, ptr_log->af).GetString (),
|
||||
_app_getprotoname (ptr_log->protocol, ptr_log->af, NULL).GetString (),
|
||||
app.LocaleString (IDS_FILTER, NULL).GetString (),
|
||||
_app_getfiltername (NULL, ptr_log->filter_name, SZ_EMPTY).GetString (),
|
||||
app.LocaleString (IDS_DIRECTION, NULL).GetString (),
|
||||
_app_getdirectionname (ptr_log->direction, ptr_log->is_loopback).GetString (),
|
||||
_app_getdirectionname (ptr_log->direction, ptr_log->is_loopback, TRUE).GetString (),
|
||||
app.LocaleString (IDS_STATE, NULL).GetString (),
|
||||
(ptr_log->is_allow ? SZ_STATE_ALLOW : SZ_STATE_BLOCK)
|
||||
);
|
||||
@@ -817,7 +817,7 @@ VOID _app_setappiteminfo (HWND hwnd, INT listview_id, INT item, SIZE_T app_hash,
|
||||
_app_getappicon (ptr_app, TRUE, &ptr_app->icon_id, NULL);
|
||||
|
||||
_r_listview_setitem (hwnd, listview_id, item, 0, ptr_app->display_name, ptr_app->icon_id, _app_getappgroup (app_hash, ptr_app));
|
||||
_r_listview_setitem (hwnd, listview_id, item, 1, _r_fmt_dateex (ptr_app->timestamp, FDTF_SHORTDATE | FDTF_SHORTTIME));
|
||||
_r_listview_setitem (hwnd, listview_id, item, 1, _r_fmt_dateex (ptr_app->timestamp, FDTF_SHORTDATE | FDTF_SHORTTIME).GetString ());
|
||||
|
||||
_r_listview_setitemcheck (hwnd, listview_id, item, ptr_app->is_enabled);
|
||||
}
|
||||
@@ -827,9 +827,9 @@ VOID _app_setruleiteminfo (HWND hwnd, INT listview_id, INT item, PITEM_RULE ptr_
|
||||
if (!listview_id || item == INVALID_INT)
|
||||
return;
|
||||
|
||||
_r_listview_setitem (hwnd, listview_id, item, 0, ptr_rule->is_readonly && ptr_rule->type == DataRuleCustom ? _r_fmt (L"%s" SZ_RULE_INTERNAL_MENU, ptr_rule->pname) : ptr_rule->pname, _app_getruleicon (ptr_rule), _app_getrulegroup (ptr_rule));
|
||||
_r_listview_setitem (hwnd, listview_id, item, 1, ptr_rule->protocol ? _app_getprotoname (ptr_rule->protocol, AF_UNSPEC) : app.LocaleString (IDS_ANY, NULL));
|
||||
_r_listview_setitem (hwnd, listview_id, item, 2, app.LocaleString (ptr_rule->direction == FWP_DIRECTION_MAX ? IDS_ANY : IDS_DIRECTION_1 + ptr_rule->direction, NULL));
|
||||
_r_listview_setitem (hwnd, listview_id, item, 0, ptr_rule->is_readonly && ptr_rule->type == DataRuleCustom ? _r_fmt (L"%s" SZ_RULE_INTERNAL_MENU, ptr_rule->pname).GetString () : ptr_rule->pname, _app_getruleicon (ptr_rule), _app_getrulegroup (ptr_rule));
|
||||
_r_listview_setitem (hwnd, listview_id, item, 1, ptr_rule->protocol ? _app_getprotoname (ptr_rule->protocol, AF_UNSPEC, NULL).GetString () : app.LocaleString (IDS_ANY, NULL).GetString ());
|
||||
_r_listview_setitem (hwnd, listview_id, item, 2, _app_getdirectionname (ptr_rule->direction, FALSE, TRUE).GetString ());
|
||||
|
||||
_r_listview_setitemcheck (hwnd, listview_id, item, ptr_rule->is_enabled);
|
||||
|
||||
@@ -1387,7 +1387,7 @@ VOID _app_profile_load_fallback ()
|
||||
_app_addapplication (NULL, PROC_SYSTEM_NAME, 0, 0, 0, FALSE, FALSE);
|
||||
|
||||
if (!_app_isappfound (config.svchost_hash))
|
||||
_app_addapplication (NULL, _r_path_expand (PATH_SVCHOST), 0, 0, 0, FALSE, FALSE);
|
||||
_app_addapplication (NULL, _r_path_expand (PATH_SVCHOST).GetString (), 0, 0, 0, FALSE, FALSE);
|
||||
|
||||
_app_setappinfo (config.ntoskrnl_hash, InfoIsUndeletable, TRUE);
|
||||
_app_setappinfo (config.svchost_hash, InfoIsUndeletable, TRUE);
|
||||
@@ -1424,9 +1424,9 @@ VOID _app_profile_load_helper (pugi::xml_node& root, ENUM_TYPE_DATA type, UINT v
|
||||
SIZE_T rule_remote_length = min (attr_rule_remote.GetLength (), RULE_RULE_CCH_MAX);
|
||||
SIZE_T rule_local_length = min (attr_rule_local.GetLength (), RULE_RULE_CCH_MAX);
|
||||
|
||||
_r_str_alloc (&ptr_rule->pname, name_length, attr_name);
|
||||
_r_str_alloc (&ptr_rule->prule_remote, rule_remote_length, attr_rule_remote);
|
||||
_r_str_alloc (&ptr_rule->prule_local, rule_local_length, attr_rule_local);
|
||||
_r_str_alloc (&ptr_rule->pname, name_length, attr_name.GetString ());
|
||||
_r_str_alloc (&ptr_rule->prule_remote, rule_remote_length, attr_rule_remote.GetString ());
|
||||
_r_str_alloc (&ptr_rule->prule_local, rule_local_length, attr_rule_local.GetString ());
|
||||
}
|
||||
|
||||
ptr_rule->direction = (FWP_DIRECTION)item.attribute (L"dir").as_int ();
|
||||
@@ -1492,14 +1492,14 @@ VOID _app_profile_load_helper (pugi::xml_node& root, ENUM_TYPE_DATA type, UINT v
|
||||
_r_str_replace (apps_rule.GetBuffer (), DIVIDER_RULE[0], DIVIDER_APP[0]); // for compat with old profiles
|
||||
|
||||
rstringvec rvc;
|
||||
_r_str_split (apps_rule, apps_rule.GetLength (), DIVIDER_APP[0], rvc);
|
||||
_r_str_split (apps_rule.GetString (), apps_rule.GetLength (), DIVIDER_APP[0], rvc);
|
||||
|
||||
for (auto& p : rvc)
|
||||
{
|
||||
_r_str_trim (p, DIVIDER_TRIM);
|
||||
|
||||
rstring app_path = _r_path_expand (p);
|
||||
SIZE_T app_hash = _r_str_hash (app_path);
|
||||
rstring app_path = _r_path_expand (p.GetString ());
|
||||
SIZE_T app_hash = _r_str_hash (app_path.GetString ());
|
||||
|
||||
if (app_hash)
|
||||
{
|
||||
@@ -1507,7 +1507,7 @@ VOID _app_profile_load_helper (pugi::xml_node& root, ENUM_TYPE_DATA type, UINT v
|
||||
continue;
|
||||
|
||||
if (!_app_isappfound (app_hash))
|
||||
app_hash = _app_addapplication (NULL, app_path, 0, 0, 0, FALSE, FALSE);
|
||||
app_hash = _app_addapplication (NULL, app_path.GetString (), 0, 0, 0, FALSE, FALSE);
|
||||
|
||||
if (ptr_rule->type == DataRuleSystem)
|
||||
_app_setappinfo (app_hash, InfoIsUndeletable, TRUE);
|
||||
@@ -1527,7 +1527,7 @@ VOID _app_profile_load_helper (pugi::xml_node& root, ENUM_TYPE_DATA type, UINT v
|
||||
if (rule_name.IsEmpty ())
|
||||
continue;
|
||||
|
||||
SIZE_T rule_hash = _r_str_hash (rule_name);
|
||||
SIZE_T rule_hash = _r_str_hash (rule_name.GetString ());
|
||||
|
||||
if (rule_hash && rules_config.find (rule_hash) == rules_config.end ())
|
||||
{
|
||||
@@ -1540,8 +1540,8 @@ VOID _app_profile_load_helper (pugi::xml_node& root, ENUM_TYPE_DATA type, UINT v
|
||||
if (version < XML_PROFILE_VER_3)
|
||||
_r_str_replace (attr_apps.GetBuffer (), DIVIDER_RULE[0], DIVIDER_APP[0]); // for compat with old profiles
|
||||
|
||||
_r_str_alloc (&ptr_config->pname, rule_name.GetLength (), rule_name);
|
||||
_r_str_alloc (&ptr_config->papps, attr_apps.GetLength (), attr_apps);
|
||||
_r_str_alloc (&ptr_config->pname, rule_name.GetLength (), rule_name.GetString ());
|
||||
_r_str_alloc (&ptr_config->papps, attr_apps.GetLength (), attr_apps.GetString ());
|
||||
|
||||
rules_config[rule_hash] = ptr_config;
|
||||
}
|
||||
@@ -1563,7 +1563,7 @@ VOID _app_profile_load_internal (LPCWSTR path, LPCWSTR path_backup, time_t* ptim
|
||||
if (path_backup)
|
||||
{
|
||||
DWORD size = 0;
|
||||
LPVOID pbuffer = _r_loadresource (app.GetHINSTANCE (), path_backup, RT_RCDATA, &size);
|
||||
PVOID pbuffer = _r_loadresource (app.GetHINSTANCE (), path_backup, RT_RCDATA, &size);
|
||||
|
||||
if (pbuffer)
|
||||
load_backup = doc_backup.load_buffer (pbuffer, size, PUGIXML_LOAD_FLAGS, PUGIXML_LOAD_ENCODING);
|
||||
@@ -1584,7 +1584,7 @@ VOID _app_profile_load_internal (LPCWSTR path, LPCWSTR path_backup, time_t* ptim
|
||||
|
||||
// show only syntax, memory and i/o errors...
|
||||
if (!load_original && load_original.status != pugi::status_file_not_found && load_original.status != pugi::status_no_document_element)
|
||||
app.LogError (L"pugi::load_file", 0, _r_fmt (L"status: %d,offset: %" TEXT (PR_PTRDIFF) L",text: %hs,file: %s", load_original.status, load_original.offset, load_original.description (), path), UID);
|
||||
app.LogError (L"pugi::load_file", 0, _r_fmt (L"status: %d,offset: %" TEXT (PR_PTRDIFF) L",text: %hs,file: %s", load_original.status, load_original.offset, load_original.description (), path).GetString (), UID);
|
||||
|
||||
if (load_original && root)
|
||||
{
|
||||
@@ -1658,7 +1658,7 @@ VOID _app_profile_load (HWND hwnd, LPCWSTR path_custom)
|
||||
{
|
||||
// show only syntax, memory and i/o errors...
|
||||
if (result.status != pugi::status_file_not_found && result.status != pugi::status_no_document_element)
|
||||
app.LogError (L"pugi::load_file", 0, _r_fmt (L"status: %d,offset: %" TEXT (PR_PTRDIFF) L",text: %hs,file: %s", result.status, result.offset, result.description (), !_r_str_isempty (path_custom) ? path_custom : config.profile_path), UID);
|
||||
app.LogError (L"pugi::load_file", 0, _r_fmt (L"status: %d,offset: %" TEXT (PR_PTRDIFF) L",text: %hs,file: %s", result.status, result.offset, result.description (), !_r_str_isempty (path_custom) ? path_custom : config.profile_path).GetString (), UID);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1794,7 +1794,7 @@ VOID _app_profile_load (HWND hwnd, LPCWSTR path_custom)
|
||||
VOID _app_profile_save (LPCWSTR path_custom)
|
||||
{
|
||||
time_t current_time = _r_unixtime_now ();
|
||||
BOOLEAN is_backuprequired = !path_custom && app.ConfigGetBoolean (L"IsBackupProfile", TRUE) && (!_r_fs_exists (config.profile_path_backup) || ((current_time - app.ConfigGetLong64 (L"BackupTimestamp", 0)) >= app.ConfigGetLong64 (L"BackupPeriod", _R_SECONDSCLOCK_HOUR (BACKUP_HOURS_PERIOD))));
|
||||
BOOLEAN is_backuprequired = !path_custom && app.ConfigGetBoolean (L"IsBackupProfile", TRUE) && (!_r_fs_exists (config.profile_path_backup) || ((current_time - app.ConfigGetLong64 (L"BackupTimestamp", 0)) >= app.ConfigGetLong64 (L"BackupPeriod", BACKUP_HOURS_PERIOD)));
|
||||
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_node root = doc.append_child (L"root");
|
||||
@@ -1916,7 +1916,7 @@ VOID _app_profile_save (LPCWSTR path_custom)
|
||||
rstring rule_apps = _app_rulesexpandapps (ptr_rule, FALSE, DIVIDER_APP);
|
||||
|
||||
if (!rule_apps.IsEmpty ())
|
||||
item.append_attribute (L"apps").set_value (rule_apps);
|
||||
item.append_attribute (L"apps").set_value (rule_apps.GetString ());
|
||||
}
|
||||
|
||||
if (ptr_rule->is_block)
|
||||
@@ -1986,7 +1986,7 @@ VOID _app_profile_save (LPCWSTR path_custom)
|
||||
item.append_attribute (L"name").set_value (ptr_config->pname);
|
||||
|
||||
if (!rule_apps.IsEmpty ())
|
||||
item.append_attribute (L"apps").set_value (rule_apps);
|
||||
item.append_attribute (L"apps").set_value (rule_apps.GetString ());
|
||||
|
||||
item.append_attribute (L"is_enabled").set_value (ptr_config->is_enabled);
|
||||
}
|
||||
|
||||
+8
-8
@@ -125,7 +125,7 @@ PACL _app_createaccesscontrollist (PACL pAcl, BOOLEAN is_secure)
|
||||
{
|
||||
PACCESS_ALLOWED_ACE pAce = NULL;
|
||||
|
||||
if (!GetAce (pAcl, cAce, (LPVOID*)&pAce))
|
||||
if (!GetAce (pAcl, cAce, (PVOID*)&pAce))
|
||||
continue;
|
||||
|
||||
if (pAce->Header.AceType == ACCESS_ALLOWED_ACE_TYPE)
|
||||
@@ -214,7 +214,7 @@ VOID _app_setsecurityinfoforengine (HANDLE hengine)
|
||||
{
|
||||
PACCESS_ALLOWED_ACE pAce = NULL;
|
||||
|
||||
if (!GetAce (pDacl, cAce, (LPVOID*)&pAce))
|
||||
if (!GetAce (pDacl, cAce, (PVOID*)&pAce))
|
||||
continue;
|
||||
|
||||
if (pAce->Header.AceType != ACCESS_ALLOWED_ACE_TYPE)
|
||||
@@ -328,7 +328,7 @@ VOID _app_setsecurityinfoforengine (HANDLE hengine)
|
||||
}
|
||||
|
||||
if (psecurityDescriptor)
|
||||
FwpmFreeMemory ((LPVOID*)&psecurityDescriptor);
|
||||
FwpmFreeMemory ((PVOID*)&psecurityDescriptor);
|
||||
}
|
||||
|
||||
VOID _app_setsecurityinfoforprovider (HANDLE hengine, const GUID* lpguid, BOOLEAN is_secure)
|
||||
@@ -359,7 +359,7 @@ VOID _app_setsecurityinfoforprovider (HANDLE hengine, const GUID* lpguid, BOOLEA
|
||||
}
|
||||
|
||||
if (psecurityDescriptor)
|
||||
FwpmFreeMemory ((LPVOID*)&psecurityDescriptor);
|
||||
FwpmFreeMemory ((PVOID*)&psecurityDescriptor);
|
||||
}
|
||||
|
||||
VOID _app_setsecurityinfoforsublayer (HANDLE hengine, const GUID* lpguid, BOOLEAN is_secure)
|
||||
@@ -390,7 +390,7 @@ VOID _app_setsecurityinfoforsublayer (HANDLE hengine, const GUID* lpguid, BOOLEA
|
||||
}
|
||||
|
||||
if (psecurityDescriptor)
|
||||
FwpmFreeMemory ((LPVOID*)&psecurityDescriptor);
|
||||
FwpmFreeMemory ((PVOID*)&psecurityDescriptor);
|
||||
}
|
||||
|
||||
VOID _app_setsecurityinfoforfilter (HANDLE hengine, const GUID* lpguid, BOOLEAN is_secure, UINT line)
|
||||
@@ -402,7 +402,7 @@ VOID _app_setsecurityinfoforfilter (HANDLE hengine, const GUID* lpguid, BOOLEAN
|
||||
|
||||
if (code != ERROR_SUCCESS)
|
||||
{
|
||||
app.LogError (L"FwpmFilterSetSecurityInfoByKey", code, _r_fmt (L"#%d", line), 0);
|
||||
app.LogError (L"FwpmFilterSetSecurityInfoByKey", code, _r_fmt (L"#%d", line).GetString (), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -415,11 +415,11 @@ VOID _app_setsecurityinfoforfilter (HANDLE hengine, const GUID* lpguid, BOOLEAN
|
||||
code = FwpmFilterSetSecurityInfoByKey (hengine, lpguid, DACL_SECURITY_INFORMATION, NULL, NULL, pNewDacl, NULL);
|
||||
|
||||
if (code != ERROR_SUCCESS)
|
||||
app.LogError (L"FwpmFilterSetSecurityInfoByKey", code, _r_fmt (L"#%d", line), 0);
|
||||
app.LogError (L"FwpmFilterSetSecurityInfoByKey", code, _r_fmt (L"#%d", line).GetString (), 0);
|
||||
|
||||
LocalFree (pNewDacl);
|
||||
}
|
||||
|
||||
if (psecurityDescriptor)
|
||||
FwpmFreeMemory ((LPVOID*)&psecurityDescriptor);
|
||||
FwpmFreeMemory ((PVOID*)&psecurityDescriptor);
|
||||
}
|
||||
+4
-4
@@ -26,15 +26,15 @@ VOID _app_timer_set (HWND hwnd, PITEM_APP ptr_app, time_t seconds)
|
||||
else
|
||||
{
|
||||
time_t current_time = _r_unixtime_now ();
|
||||
BOOL is_created = FALSE;
|
||||
BOOLEAN is_created = FALSE;
|
||||
|
||||
if (_r_fs_isvalidhandle (ptr_app->htimer))
|
||||
{
|
||||
is_created = ChangeTimerQueueTimer (config.htimer, ptr_app->htimer, (DWORD)seconds * _R_SECONDSCLOCK_MSEC, 0);
|
||||
is_created = !!ChangeTimerQueueTimer (config.htimer, ptr_app->htimer, _r_calc_seconds2milliseconds (DWORD, seconds), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
is_created = CreateTimerQueueTimer (&ptr_app->htimer, config.htimer, &_app_timer_callback, (PVOID)app_hash, (DWORD)seconds * _R_SECONDSCLOCK_MSEC, 0, WT_EXECUTEONLYONCE | WT_EXECUTEINTIMERTHREAD);
|
||||
is_created = !!CreateTimerQueueTimer (&ptr_app->htimer, config.htimer, &_app_timer_callback, (PVOID)app_hash, _r_calc_seconds2milliseconds (DWORD, seconds), 0, WT_EXECUTEONLYONCE | WT_EXECUTEINTIMERTHREAD);
|
||||
}
|
||||
|
||||
if (is_created)
|
||||
@@ -164,5 +164,5 @@ VOID CALLBACK _app_timer_callback (PVOID lpParameter, BOOLEAN TimerOrWaitFired)
|
||||
_r_listview_redraw (hwnd, listview_id, INVALID_INT);
|
||||
|
||||
if (app.ConfigGetBoolean (L"IsNotificationsTimer", TRUE))
|
||||
_r_tray_popup (hwnd, UID, NIIF_INFO | (app.ConfigGetBoolean (L"IsNotificationsSound", TRUE) ? 0 : NIIF_NOSOUND), APP_NAME, _r_fmt (app.LocaleString (IDS_STATUS_TIMER_DONE, NULL), ptr_app->display_name));
|
||||
_r_tray_popup (hwnd, UID, NIIF_INFO | (app.ConfigGetBoolean (L"IsNotificationsSound", TRUE) ? 0 : NIIF_NOSOUND), APP_NAME, _r_fmt (app.LocaleString (IDS_STATUS_TIMER_DONE, NULL).GetString (), ptr_app->display_name).GetString ());
|
||||
}
|
||||
+22
-22
@@ -31,7 +31,7 @@ ENUM_INSTALL_TYPE _wfp_isproviderinstalled (HANDLE hengine)
|
||||
|
||||
if (FwpmProviderGetByKey (hengine, &GUID_WfpProvider, &ptr_provider) == ERROR_SUCCESS)
|
||||
{
|
||||
FwpmFreeMemory ((LPVOID*)&ptr_provider);
|
||||
FwpmFreeMemory ((PVOID*)&ptr_provider);
|
||||
|
||||
return InstallEnabledTemporary;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ ENUM_INSTALL_TYPE _wfp_issublayerinstalled (HANDLE hengine)
|
||||
|
||||
if (FwpmSubLayerGetByKey (hengine, &GUID_WfpSublayer, &ptr_sublayer) == ERROR_SUCCESS)
|
||||
{
|
||||
FwpmFreeMemory ((LPVOID*)&ptr_sublayer);
|
||||
FwpmFreeMemory ((PVOID*)&ptr_sublayer);
|
||||
|
||||
return InstallEnabledTemporary;
|
||||
}
|
||||
@@ -519,7 +519,7 @@ BOOLEAN _wfp_transact_start (HANDLE hengine, UINT line)
|
||||
|
||||
if (code != ERROR_SUCCESS)
|
||||
{
|
||||
app.LogError (L"FwpmTransactionBegin", code, _r_fmt (L"#%d", line), UID);
|
||||
app.LogError (L"FwpmTransactionBegin", code, _r_fmt (L"#%d", line).GetString (), UID);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ BOOLEAN _wfp_transact_commit (HANDLE hengine, UINT line)
|
||||
{
|
||||
FwpmTransactionAbort (hengine);
|
||||
|
||||
app.LogError (L"FwpmTransactionCommit", code, _r_fmt (L"#%d", line), UID);
|
||||
app.LogError (L"FwpmTransactionCommit", code, _r_fmt (L"#%d", line).GetString (), UID);
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
@@ -559,10 +559,10 @@ DWORD _wfp_createfilter (HANDLE hengine, LPCWSTR name, FWPM_FILTER_CONDITION* lp
|
||||
{
|
||||
FWPM_FILTER filter = {0};
|
||||
|
||||
WCHAR fltr_name[128] = {0};
|
||||
WCHAR fltr_name[128];
|
||||
_r_str_copy (fltr_name, RTL_NUMBER_OF (fltr_name), APP_NAME);
|
||||
|
||||
WCHAR fltr_desc[128] = {0};
|
||||
WCHAR fltr_desc[128];
|
||||
_r_str_copy (fltr_desc, RTL_NUMBER_OF (fltr_desc), _r_str_isempty (name) ? SZ_EMPTY : name);
|
||||
|
||||
filter.displayData.name = fltr_name;
|
||||
@@ -738,7 +738,7 @@ BOOLEAN _wfp_createrulefilter (HANDLE hengine, LPCWSTR name, SIZE_T app_hash, LP
|
||||
|
||||
if (!ptr_app_object)
|
||||
{
|
||||
app.LogError (TEXT (__FUNCTION__), 0, _r_fmt (L"App \"%" TEXT (PR_SIZE_T) L"\" not found!", app_hash), 0);
|
||||
app.LogError (TEXT (__FUNCTION__), 0, _r_fmt (L"App \"%" TEXT (PR_SIZE_T) L"\" not found!", app_hash).GetString (), 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ BOOLEAN _wfp_createrulefilter (HANDLE hengine, LPCWSTR name, SIZE_T app_hash, LP
|
||||
|
||||
if (!ptr_app)
|
||||
{
|
||||
app.LogError (TEXT (__FUNCTION__), 0, _r_fmt (L"App \"%" TEXT (PR_SIZE_T) L"\" not found!", app_hash), 0);
|
||||
app.LogError (TEXT (__FUNCTION__), 0, _r_fmt (L"App \"%" TEXT (PR_SIZE_T) L"\" not found!", app_hash).GetString (), 0);
|
||||
_r_obj2_dereference (ptr_app_object);
|
||||
|
||||
return FALSE;
|
||||
@@ -935,7 +935,7 @@ BOOLEAN _wfp_createrulefilter (HANDLE hengine, LPCWSTR name, SIZE_T app_hash, LP
|
||||
{
|
||||
for (auto &p : rvc)
|
||||
{
|
||||
if (!_wfp_createrulefilter (hengine, name, app_hash, p, NULL, protocol, af, dir, weight, action, flag, pmfarr))
|
||||
if (!_wfp_createrulefilter (hengine, name, app_hash, p.GetString (), NULL, protocol, af, dir, weight, action, flag, pmfarr))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1124,10 +1124,10 @@ BOOLEAN _wfp_create4filters (HANDLE hengine, const OBJECTS_VEC& ptr_rules, UINT
|
||||
// apply rules for services hosts
|
||||
if (ptr_rule->is_forservices)
|
||||
{
|
||||
if (!_wfp_createrulefilter (hengine, ptr_rule->pname, config.ntoskrnl_hash, rule_remote, rule_local, ptr_rule->protocol, ptr_rule->af, ptr_rule->direction, ptr_rule->weight, ptr_rule->is_block ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT, 0, &guids))
|
||||
if (!_wfp_createrulefilter (hengine, ptr_rule->pname, config.ntoskrnl_hash, rule_remote.GetString (), rule_local.GetString (), ptr_rule->protocol, ptr_rule->af, ptr_rule->direction, ptr_rule->weight, ptr_rule->is_block ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT, 0, &guids))
|
||||
is_haveerrors = TRUE;
|
||||
|
||||
if (!_wfp_createrulefilter (hengine, ptr_rule->pname, config.svchost_hash, rule_remote, rule_local, ptr_rule->protocol, ptr_rule->af, ptr_rule->direction, ptr_rule->weight, ptr_rule->is_block ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT, 0, &guids))
|
||||
if (!_wfp_createrulefilter (hengine, ptr_rule->pname, config.svchost_hash, rule_remote.GetString (), rule_local.GetString (), ptr_rule->protocol, ptr_rule->af, ptr_rule->direction, ptr_rule->weight, ptr_rule->is_block ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT, 0, &guids))
|
||||
is_haveerrors = TRUE;
|
||||
}
|
||||
|
||||
@@ -1138,13 +1138,13 @@ BOOLEAN _wfp_create4filters (HANDLE hengine, const OBJECTS_VEC& ptr_rules, UINT
|
||||
if (ptr_rule->is_forservices && (papps.first == config.ntoskrnl_hash || papps.first == config.svchost_hash))
|
||||
continue;
|
||||
|
||||
if (!_wfp_createrulefilter (hengine, ptr_rule->pname, papps.first, rule_remote, rule_local, ptr_rule->protocol, ptr_rule->af, ptr_rule->direction, ptr_rule->weight, ptr_rule->is_block ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT, 0, &guids))
|
||||
if (!_wfp_createrulefilter (hengine, ptr_rule->pname, papps.first, rule_remote.GetString (), rule_local.GetString (), ptr_rule->protocol, ptr_rule->af, ptr_rule->direction, ptr_rule->weight, ptr_rule->is_block ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT, 0, &guids))
|
||||
is_haveerrors = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_wfp_createrulefilter (hengine, ptr_rule->pname, 0, rule_remote, rule_local, ptr_rule->protocol, ptr_rule->af, ptr_rule->direction, ptr_rule->weight, ptr_rule->is_block ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT, 0, &guids))
|
||||
if (!_wfp_createrulefilter (hengine, ptr_rule->pname, 0, rule_remote.GetString (), rule_local.GetString (), ptr_rule->protocol, ptr_rule->af, ptr_rule->direction, ptr_rule->weight, ptr_rule->is_block ? FWP_ACTION_BLOCK : FWP_ACTION_PERMIT, 0, &guids))
|
||||
is_haveerrors = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1628,7 +1628,7 @@ SIZE_T _wfp_dumpfilters (HANDLE hengine, const GUID* pprovider_id, GUIDS_VEC* pt
|
||||
ptr_filters->push_back (pfilter->filterKey);
|
||||
}
|
||||
|
||||
FwpmFreeMemory ((LPVOID*)&matchingFwpFilter);
|
||||
FwpmFreeMemory ((PVOID*)&matchingFwpFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1651,7 +1651,7 @@ BOOLEAN _mps_firewallapi (PBOOLEAN pis_enabled, PBOOLEAN pis_enable)
|
||||
BOOLEAN result = FALSE;
|
||||
|
||||
INetFwPolicy2* pNetFwPolicy2 = NULL;
|
||||
HRESULT hr = CoCreateInstance (__uuidof (NetFwPolicy2), NULL, CLSCTX_INPROC_SERVER, __uuidof (INetFwPolicy2), (LPVOID*)&pNetFwPolicy2);
|
||||
HRESULT hr = CoCreateInstance (__uuidof (NetFwPolicy2), NULL, CLSCTX_INPROC_SERVER, __uuidof (INetFwPolicy2), (PVOID*)&pNetFwPolicy2);
|
||||
|
||||
if (SUCCEEDED (hr) && pNetFwPolicy2)
|
||||
{
|
||||
@@ -1694,7 +1694,7 @@ BOOLEAN _mps_firewallapi (PBOOLEAN pis_enabled, PBOOLEAN pis_enable)
|
||||
result = TRUE;
|
||||
|
||||
else
|
||||
app.LogError (L"put_FirewallEnabled", hr, _r_fmt (L"%d", type), 0);
|
||||
app.LogError (L"put_FirewallEnabled", hr, _r_fmt (L"%d", type).GetString (), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1814,9 +1814,9 @@ DWORD _FwpmGetAppIdFromFileName1 (LPCWSTR path, FWP_BYTE_BLOB** lpblob, ENUM_TYP
|
||||
{
|
||||
path_buff = path;
|
||||
|
||||
if (_r_str_hash (path_buff) == config.ntoskrnl_hash)
|
||||
if (_r_str_hash (path_buff.GetString ()) == config.ntoskrnl_hash)
|
||||
{
|
||||
if (ByteBlobAlloc ((LPVOID)path_buff.GetString (), (path_buff.GetLength () + 1) * sizeof (WCHAR), lpblob))
|
||||
if (ByteBlobAlloc ((PVOID)path_buff.GetString (), (path_buff.GetLength () + 1) * sizeof (WCHAR), lpblob))
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
else
|
||||
@@ -1838,12 +1838,12 @@ DWORD _FwpmGetAppIdFromFileName1 (LPCWSTR path, FWP_BYTE_BLOB** lpblob, ENUM_TYP
|
||||
else
|
||||
{
|
||||
// file path (root)
|
||||
WCHAR path_root[MAX_PATH] = {0};
|
||||
WCHAR path_root[MAX_PATH];
|
||||
_r_str_copy (path_root, RTL_NUMBER_OF (path_root), path);
|
||||
PathStripToRoot (path_root);
|
||||
|
||||
// file path (without root)
|
||||
WCHAR path_noroot[MAX_PATH] = {0};
|
||||
WCHAR path_noroot[MAX_PATH];
|
||||
_r_str_copy (path_noroot, RTL_NUMBER_OF (path_noroot), PathSkipRoot (path));
|
||||
|
||||
path_buff = path_root;
|
||||
@@ -1862,7 +1862,7 @@ DWORD _FwpmGetAppIdFromFileName1 (LPCWSTR path, FWP_BYTE_BLOB** lpblob, ENUM_TYP
|
||||
return code;
|
||||
}
|
||||
|
||||
if (ByteBlobAlloc ((LPVOID)path_buff.GetString (), (path_buff.GetLength () + 1) * sizeof (WCHAR), lpblob))
|
||||
if (ByteBlobAlloc ((PVOID)path_buff.GetString (), (path_buff.GetLength () + 1) * sizeof (WCHAR), lpblob))
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -1873,7 +1873,7 @@ DWORD _FwpmGetAppIdFromFileName1 (LPCWSTR path, FWP_BYTE_BLOB** lpblob, ENUM_TYP
|
||||
if (type == DataAppDevice)
|
||||
_r_str_tolower (path_buff.GetBuffer ()); // lower is important!
|
||||
|
||||
if (ByteBlobAlloc ((LPVOID)path_buff.GetString (), (path_buff.GetLength () + 1) * sizeof (WCHAR), lpblob))
|
||||
if (ByteBlobAlloc ((PVOID)path_buff.GetString (), (path_buff.GetLength () + 1) * sizeof (WCHAR), lpblob))
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user