From a124d5b1f87c01a0413178a7de4dfda7ea31fc0e Mon Sep 17 00:00:00 2001 From: henrypp Date: Wed, 10 Jun 2020 22:08:00 +0600 Subject: [PATCH] code cosmetics --- src/controls.cpp | 50 ++-- src/editor.cpp | 116 +++++----- src/helper.cpp | 320 ++++++++++++++------------ src/helper.hpp | 12 +- src/log.cpp | 64 +++--- src/log.hpp | 12 +- src/main.cpp | 521 +++++++++++++++++++++--------------------- src/main.hpp | 6 +- src/notifications.cpp | 177 +++++++------- src/profile.cpp | 66 +++--- src/security.cpp | 16 +- src/timer.cpp | 8 +- src/wfp.cpp | 44 ++-- 13 files changed, 722 insertions(+), 690 deletions(-) diff --git a/src/controls.cpp b/src/controls.cpp index 21a1a3a1..48358158 100644 --- a/src/controls.cpp +++ b/src/controls.cpp @@ -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) { diff --git a/src/editor.cpp b/src/editor.cpp index 98d851a8..cab974bd 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -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); diff --git a/src/helper.cpp b/src/helper.cpp index 53df6f8e..65edd0ad 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -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; } } diff --git a/src/helper.hpp b/src/helper.hpp index 6ea8a372..1c76a298 100644 --- a/src/helper.hpp +++ b/src/helper.hpp @@ -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); diff --git a/src/log.cpp b/src/log.cpp index 88f8d94a..cfbe3998 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -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; diff --git a/src/log.hpp b/src/log.hpp index e70a9be3..be3188f5 100644 --- a/src/log.hpp +++ b/src/log.hpp @@ -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); diff --git a/src/main.cpp b/src/main.cpp index 063a1b38..3037522d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ UINT WM_FINDMSGSTRING = RegisterWindowMessage (FINDMSGSTRING); -THREAD_FN ApplyThread (LPVOID lparam) +THREAD_FN ApplyThread (PVOID lparam) { PITEM_CONTEXT pcontext = (PITEM_CONTEXT)lparam; @@ -49,7 +49,7 @@ THREAD_FN ApplyThread (LPVOID lparam) return _r_sys_endthread (ERROR_SUCCESS); } -THREAD_FN NetworkMonitorThread (LPVOID lparam) +THREAD_FN NetworkMonitorThread (PVOID lparam) { DWORD network_timeout = app.ConfigGetUlong (L"NetworkTimeout", NETWORK_TIMEOUT); @@ -93,14 +93,14 @@ THREAD_FN NetworkMonitorThread (LPVOID lparam) _r_listview_setitem (hwnd, network_listview_id, item_id, 1, !_r_str_isempty (local_fmt) ? local_fmt : SZ_EMPTY); _r_listview_setitem (hwnd, network_listview_id, item_id, 3, !_r_str_isempty (remote_fmt) ? remote_fmt : SZ_EMPTY); - _r_listview_setitem (hwnd, network_listview_id, item_id, 5, _app_getprotoname (ptr_network->protocol, ptr_network->af)); - _r_listview_setitem (hwnd, network_listview_id, item_id, 6, _app_getstatename (ptr_network->state, NULL)); + _r_listview_setitem (hwnd, network_listview_id, item_id, 5, _app_getprotoname (ptr_network->protocol, ptr_network->af, NULL).GetString ()); + _r_listview_setitem (hwnd, network_listview_id, item_id, 6, _app_getconnectionstatusname (ptr_network->state, NULL).GetString ()); if (ptr_network->local_port) - _r_listview_setitem (hwnd, network_listview_id, item_id, 2, _app_formatport (ptr_network->local_port, TRUE)); + _r_listview_setitem (hwnd, network_listview_id, item_id, 2, _app_formatport (ptr_network->local_port, TRUE).GetString ()); if (ptr_network->remote_port) - _r_listview_setitem (hwnd, network_listview_id, item_id, 4, _app_formatport (ptr_network->remote_port, TRUE)); + _r_listview_setitem (hwnd, network_listview_id, item_id, 4, _app_formatport (ptr_network->remote_port, TRUE).GetString ()); SAFE_DELETE_MEMORY (local_fmt); SAFE_DELETE_MEMORY (remote_fmt); @@ -204,7 +204,7 @@ BOOLEAN _app_changefilters (HWND hwnd, BOOLEAN is_install, BOOLEAN is_forced) pcontext->hwnd = hwnd; pcontext->is_install = is_install; - HANDLE hthread = _r_sys_createthreadex (&ApplyThread, (LPVOID)pcontext, TRUE, THREAD_PRIORITY_HIGHEST); + HANDLE hthread = _r_sys_createthreadex (&ApplyThread, (PVOID)pcontext, TRUE, THREAD_PRIORITY_HIGHEST); if (!hthread) { @@ -249,17 +249,18 @@ VOID addcolor (UINT locale_id, LPCWSTR config_name, BOOLEAN is_enabled, LPCWSTR BOOLEAN _app_installmessage (HWND hwnd, BOOLEAN is_install) { - WCHAR flag[64] = {0}; + WCHAR radio_text_1[128]; + WCHAR radio_text_2[128]; - WCHAR button_text_1[64] = {0}; - WCHAR button_text_2[64] = {0}; + WCHAR str_main[256]; - WCHAR radio_text_1[128] = {0}; - WCHAR radio_text_2[128] = {0}; + WCHAR str_flag[128]; - WCHAR main[256] = {0}; + WCHAR str_button_text_1[64]; + WCHAR str_button_text_2[64]; TASKDIALOGCONFIG tdc = {0}; + TASKDIALOG_BUTTON td_buttons[2]; TASKDIALOG_BUTTON td_radios[2]; @@ -269,8 +270,8 @@ BOOLEAN _app_installmessage (HWND hwnd, BOOLEAN is_install) tdc.pszWindowTitle = APP_NAME; tdc.pszMainIcon = is_install ? TD_INFORMATION_ICON : TD_WARNING_ICON; //tdc.dwCommonButtons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON; - tdc.pszContent = main; - tdc.pszVerificationText = flag; + tdc.pszContent = str_main; + tdc.pszVerificationText = str_flag; tdc.pfCallback = &_r_msg_callback; tdc.lpCallbackData = MAKELONG (0, TRUE); // on top @@ -280,18 +281,18 @@ BOOLEAN _app_installmessage (HWND hwnd, BOOLEAN is_install) tdc.nDefaultButton = IDYES; td_buttons[0].nButtonID = IDYES; - td_buttons[0].pszButtonText = button_text_1; + td_buttons[0].pszButtonText = str_button_text_1; td_buttons[1].nButtonID = IDNO; - td_buttons[1].pszButtonText = button_text_2; + td_buttons[1].pszButtonText = str_button_text_2; - _r_str_copy (button_text_1, RTL_NUMBER_OF (button_text_1), app.LocaleString (is_install ? IDS_TRAY_START : IDS_TRAY_STOP, NULL)); - _r_str_copy (button_text_2, RTL_NUMBER_OF (button_text_2), app.LocaleString (IDS_CLOSE, NULL)); + _r_str_copy (str_button_text_1, RTL_NUMBER_OF (str_button_text_1), app.LocaleString (is_install ? IDS_TRAY_START : IDS_TRAY_STOP, NULL).GetString ()); + _r_str_copy (str_button_text_2, RTL_NUMBER_OF (str_button_text_2), app.LocaleString (IDS_CLOSE, NULL).GetString ()); if (is_install) { - _r_str_copy (main, RTL_NUMBER_OF (main), app.LocaleString (IDS_QUESTION_START, NULL)); - _r_str_copy (flag, RTL_NUMBER_OF (flag), app.LocaleString (IDS_DISABLEWINDOWSFIREWALL_CHK, NULL)); + _r_str_copy (str_main, RTL_NUMBER_OF (str_main), app.LocaleString (IDS_QUESTION_START, NULL).GetString ()); + _r_str_copy (str_flag, RTL_NUMBER_OF (str_flag), app.LocaleString (IDS_DISABLEWINDOWSFIREWALL_CHK, NULL).GetString ()); tdc.pRadioButtons = td_radios; tdc.cRadioButtons = RTL_NUMBER_OF (td_radios); @@ -304,32 +305,32 @@ BOOLEAN _app_installmessage (HWND hwnd, BOOLEAN is_install) td_radios[1].nButtonID = IDNO; td_radios[1].pszButtonText = radio_text_2; - _r_str_copy (radio_text_1, RTL_NUMBER_OF (radio_text_1), app.LocaleString (IDS_INSTALL_PERMANENT, NULL)); - _r_str_copy (radio_text_2, RTL_NUMBER_OF (radio_text_2), app.LocaleString (IDS_INSTALL_TEMPORARY, NULL)); + _r_str_copy (radio_text_1, RTL_NUMBER_OF (radio_text_1), app.LocaleString (IDS_INSTALL_PERMANENT, NULL).GetString ()); + _r_str_copy (radio_text_2, RTL_NUMBER_OF (radio_text_2), app.LocaleString (IDS_INSTALL_TEMPORARY, NULL).GetString ()); if (app.ConfigGetBoolean (L"IsDisableWindowsFirewallChecked", TRUE)) tdc.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED; } else { - _r_str_copy (main, RTL_NUMBER_OF (main), app.LocaleString (IDS_QUESTION_STOP, NULL)); - _r_str_copy (flag, RTL_NUMBER_OF (flag), app.LocaleString (IDS_ENABLEWINDOWSFIREWALL_CHK, NULL)); + _r_str_copy (str_main, RTL_NUMBER_OF (str_main), app.LocaleString (IDS_QUESTION_STOP, NULL).GetString ()); + _r_str_copy (str_flag, RTL_NUMBER_OF (str_flag), app.LocaleString (IDS_ENABLEWINDOWSFIREWALL_CHK, NULL).GetString ()); if (app.ConfigGetBoolean (L"IsEnableWindowsFirewallChecked", TRUE)) tdc.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED; } - INT message_code; - INT radio_code; + INT command_id; + INT radio_id; BOOL is_flagchecked; - if (_r_msg_taskdialog (&tdc, &message_code, &radio_code, &is_flagchecked)) + if (_r_msg_taskdialog (&tdc, &command_id, &radio_id, &is_flagchecked)) { - if (message_code == IDYES) + if (command_id == IDYES) { if (is_install) { - config.is_filterstemporary = (radio_code == IDNO); + config.is_filterstemporary = (radio_id == IDNO); app.ConfigSetBoolean (L"IsDisableWindowsFirewallChecked", !!is_flagchecked); @@ -714,7 +715,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam _r_fastlock_acquireshared (&lock_checkbox); - _r_listview_additem (hwnd, IDC_COLORS, item, 0, app.LocaleString (ptr_clr->locale_id, NULL), config.icon_id, I_GROUPIDNONE, (LPARAM)ptr_clr); + _r_listview_additem (hwnd, IDC_COLORS, item, 0, app.LocaleString (ptr_clr->locale_id, NULL).GetString (), config.icon_id, I_GROUPIDNONE, (LPARAM)ptr_clr); _r_listview_setitemcheck (hwnd, IDC_COLORS, item, app.ConfigGetBoolean (ptr_clr->pcfg_name, ptr_clr->is_enabled, L"colors")); _r_fastlock_releaseshared (&lock_checkbox); @@ -731,7 +732,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam CheckDlgButton (hwnd, IDC_NOTIFICATIONSOUND_CHK, app.ConfigGetBoolean (L"IsNotificationsSound", TRUE) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton (hwnd, IDC_NOTIFICATIONONTRAY_CHK, app.ConfigGetBoolean (L"IsNotificationsOnTray", FALSE) ? BST_CHECKED : BST_UNCHECKED); - SendDlgItemMessage (hwnd, IDC_NOTIFICATIONTIMEOUT, UDM_SETRANGE32, 0, _R_SECONDSCLOCK_DAY (7)); + SendDlgItemMessage (hwnd, IDC_NOTIFICATIONTIMEOUT, UDM_SETRANGE32, 0, _r_calc_days2seconds (LPARAM, 7)); SendDlgItemMessage (hwnd, IDC_NOTIFICATIONTIMEOUT, UDM_SETPOS32, 0, (LPARAM)app.ConfigGetUlong (L"NotificationsTimeout", NOTIFY_TIMEOUT_DEFAULT)); CheckDlgButton (hwnd, IDC_EXCLUDEBLOCKLIST_CHK, app.ConfigGetBoolean (L"IsExcludeBlocklist", TRUE) ? BST_CHECKED : BST_UNCHECKED); @@ -746,14 +747,14 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam { CheckDlgButton (hwnd, IDC_ENABLELOG_CHK, app.ConfigGetBoolean (L"IsLogEnabled", FALSE) ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemText (hwnd, IDC_LOGPATH, app.ConfigGetString (L"LogPath", LOG_PATH_DEFAULT)); - SetDlgItemText (hwnd, IDC_LOGVIEWER, app.ConfigGetString (L"LogViewer", LOG_VIEWER_DEFAULT)); + SetDlgItemText (hwnd, IDC_LOGPATH, app.ConfigGetString (L"LogPath", LOG_PATH_DEFAULT).GetString ()); + SetDlgItemText (hwnd, IDC_LOGVIEWER, app.ConfigGetString (L"LogViewer", LOG_VIEWER_DEFAULT).GetString ()); UDACCEL ud = {0}; ud.nInc = 64; // set step to 64kb SendDlgItemMessage (hwnd, IDC_LOGSIZELIMIT, UDM_SETACCEL, 1, (LPARAM)&ud); - SendDlgItemMessage (hwnd, IDC_LOGSIZELIMIT, UDM_SETRANGE32, 64, _R_BYTESIZE_KB * 512); + SendDlgItemMessage (hwnd, IDC_LOGSIZELIMIT, UDM_SETRANGE32, 64, _r_calc_kilobytes2bytes (LPARAM, 512)); SendDlgItemMessage (hwnd, IDC_LOGSIZELIMIT, UDM_SETPOS32, 0, (LPARAM)app.ConfigGetUlong (L"LogSizeLimitKb", LOG_SIZE_LIMIT_DEFAULT)); CheckDlgButton (hwnd, IDC_ENABLEUILOG_CHK, app.ConfigGetBoolean (L"IsLogUiEnabled", FALSE) ? BST_CHECKED : BST_UNCHECKED); @@ -782,69 +783,69 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam rstring recommended = app.LocaleString (IDS_RECOMMENDED, NULL); // localize titles - SetDlgItemText (hwnd, IDC_TITLE_GENERAL, app.LocaleString (IDS_TITLE_GENERAL, L":")); - SetDlgItemText (hwnd, IDC_TITLE_LANGUAGE, app.LocaleString (IDS_TITLE_LANGUAGE, L": (Language)")); - SetDlgItemText (hwnd, IDC_TITLE_BLOCKLIST_SPY, app.LocaleString (IDS_BLOCKLIST_SPY, L":")); - SetDlgItemText (hwnd, IDC_TITLE_BLOCKLIST_UPDATE, app.LocaleString (IDS_BLOCKLIST_UPDATE, L":")); - SetDlgItemText (hwnd, IDC_TITLE_BLOCKLIST_EXTRA, app.LocaleString (IDS_BLOCKLIST_EXTRA, L": (Skype, Bing, Live, Outlook, etc.)")); - SetDlgItemText (hwnd, IDC_TITLE_CONNECTIONS, app.LocaleString (IDS_TAB_NETWORK, L":")); - SetDlgItemText (hwnd, IDC_TITLE_SECURITY, app.LocaleString (IDS_TITLE_SECURITY, L":")); - SetDlgItemText (hwnd, IDC_TITLE_CONFIRMATIONS, app.LocaleString (IDS_TITLE_CONFIRMATIONS, L":")); - SetDlgItemText (hwnd, IDC_TITLE_HIGHLIGHTING, app.LocaleString (IDS_TITLE_HIGHLIGHTING, L":")); - SetDlgItemText (hwnd, IDC_TITLE_NOTIFICATIONS, app.LocaleString (IDS_TITLE_NOTIFICATIONS, L":")); - SetDlgItemText (hwnd, IDC_TITLE_LOGGING, app.LocaleString (IDS_TITLE_LOGGING, L":")); - SetDlgItemText (hwnd, IDC_TITLE_INTERFACE, app.LocaleString (IDS_TITLE_INTERFACE, L":")); - SetDlgItemText (hwnd, IDC_TITLE_EXCLUDE, app.LocaleString (IDS_TITLE_EXCLUDE, L":")); - SetDlgItemText (hwnd, IDC_TITLE_ADVANCED, app.LocaleString (IDS_TITLE_ADVANCED, L":")); + SetDlgItemText (hwnd, IDC_TITLE_GENERAL, app.LocaleString (IDS_TITLE_GENERAL, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_LANGUAGE, app.LocaleString (IDS_TITLE_LANGUAGE, L": (Language)").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_BLOCKLIST_SPY, app.LocaleString (IDS_BLOCKLIST_SPY, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_BLOCKLIST_UPDATE, app.LocaleString (IDS_BLOCKLIST_UPDATE, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_BLOCKLIST_EXTRA, app.LocaleString (IDS_BLOCKLIST_EXTRA, L": (Skype, Bing, Live, Outlook, etc.)").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_CONNECTIONS, app.LocaleString (IDS_TAB_NETWORK, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_SECURITY, app.LocaleString (IDS_TITLE_SECURITY, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_CONFIRMATIONS, app.LocaleString (IDS_TITLE_CONFIRMATIONS, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_HIGHLIGHTING, app.LocaleString (IDS_TITLE_HIGHLIGHTING, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_NOTIFICATIONS, app.LocaleString (IDS_TITLE_NOTIFICATIONS, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_LOGGING, app.LocaleString (IDS_TITLE_LOGGING, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_INTERFACE, app.LocaleString (IDS_TITLE_INTERFACE, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_EXCLUDE, app.LocaleString (IDS_TITLE_EXCLUDE, L":").GetString ()); + SetDlgItemText (hwnd, IDC_TITLE_ADVANCED, app.LocaleString (IDS_TITLE_ADVANCED, L":").GetString ()); switch (dialog_id) { case IDD_SETTINGS_GENERAL: { - SetDlgItemText (hwnd, IDC_ALWAYSONTOP_CHK, app.LocaleString (IDS_ALWAYSONTOP_CHK, NULL)); - SetDlgItemText (hwnd, IDC_LOADONSTARTUP_CHK, app.LocaleString (IDS_LOADONSTARTUP_CHK, NULL)); - SetDlgItemText (hwnd, IDC_STARTMINIMIZED_CHK, app.LocaleString (IDS_STARTMINIMIZED_CHK, NULL)); - SetDlgItemText (hwnd, IDC_SKIPUACWARNING_CHK, app.LocaleString (IDS_SKIPUACWARNING_CHK, NULL)); - SetDlgItemText (hwnd, IDC_CHECKUPDATES_CHK, app.LocaleString (IDS_CHECKUPDATES_CHK, NULL)); - SetDlgItemText (hwnd, IDC_CHECKUPDATESBETA_CHK, app.LocaleString (IDS_CHECKUPDATESBETA_CHK, NULL)); + SetDlgItemText (hwnd, IDC_ALWAYSONTOP_CHK, app.LocaleString (IDS_ALWAYSONTOP_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_LOADONSTARTUP_CHK, app.LocaleString (IDS_LOADONSTARTUP_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_STARTMINIMIZED_CHK, app.LocaleString (IDS_STARTMINIMIZED_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_SKIPUACWARNING_CHK, app.LocaleString (IDS_SKIPUACWARNING_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_CHECKUPDATES_CHK, app.LocaleString (IDS_CHECKUPDATES_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_CHECKUPDATESBETA_CHK, app.LocaleString (IDS_CHECKUPDATESBETA_CHK, NULL).GetString ()); - SetDlgItemText (hwnd, IDC_LANGUAGE_HINT, app.LocaleString (IDS_LANGUAGE_HINT, NULL)); + SetDlgItemText (hwnd, IDC_LANGUAGE_HINT, app.LocaleString (IDS_LANGUAGE_HINT, NULL).GetString ()); break; } case IDD_SETTINGS_RULES: { - SetDlgItemText (hwnd, IDC_RULE_BLOCKOUTBOUND, app.LocaleString (IDS_RULE_BLOCKOUTBOUND, _r_fmt (L" (%s)", recommended.GetString ()))); - SetDlgItemText (hwnd, IDC_RULE_BLOCKINBOUND, app.LocaleString (IDS_RULE_BLOCKINBOUND, _r_fmt (L" (%s)", recommended.GetString ()))); + SetDlgItemText (hwnd, IDC_RULE_BLOCKOUTBOUND, app.LocaleString (IDS_RULE_BLOCKOUTBOUND, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); + SetDlgItemText (hwnd, IDC_RULE_BLOCKINBOUND, app.LocaleString (IDS_RULE_BLOCKINBOUND, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); - SetDlgItemText (hwnd, IDC_RULE_ALLOWLOOPBACK, app.LocaleString (IDS_RULE_ALLOWLOOPBACK, _r_fmt (L" (%s)", recommended.GetString ()))); - SetDlgItemText (hwnd, IDC_RULE_ALLOW6TO4, app.LocaleString (IDS_RULE_ALLOW6TO4, _r_fmt (L" (%s)", recommended.GetString ()))); + SetDlgItemText (hwnd, IDC_RULE_ALLOWLOOPBACK, app.LocaleString (IDS_RULE_ALLOWLOOPBACK, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); + SetDlgItemText (hwnd, IDC_RULE_ALLOW6TO4, app.LocaleString (IDS_RULE_ALLOW6TO4, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); - SetDlgItemText (hwnd, IDC_SECUREFILTERS_CHK, app.LocaleString (IDS_SECUREFILTERS_CHK, _r_fmt (L" (%s)", recommended.GetString ()))); - SetDlgItemText (hwnd, IDC_USESTEALTHMODE_CHK, app.LocaleString (IDS_USESTEALTHMODE_CHK, _r_fmt (L" (%s)", recommended.GetString ()))); - SetDlgItemText (hwnd, IDC_INSTALLBOOTTIMEFILTERS_CHK, app.LocaleString (IDS_INSTALLBOOTTIMEFILTERS_CHK, _r_fmt (L" (%s)", recommended.GetString ()))); + SetDlgItemText (hwnd, IDC_SECUREFILTERS_CHK, app.LocaleString (IDS_SECUREFILTERS_CHK, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); + SetDlgItemText (hwnd, IDC_USESTEALTHMODE_CHK, app.LocaleString (IDS_USESTEALTHMODE_CHK, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); + SetDlgItemText (hwnd, IDC_INSTALLBOOTTIMEFILTERS_CHK, app.LocaleString (IDS_INSTALLBOOTTIMEFILTERS_CHK, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); - SetDlgItemText (hwnd, IDC_USENETWORKRESOLUTION_CHK, app.LocaleString (IDS_USENETWORKRESOLUTION_CHK, NULL)); - SetDlgItemText (hwnd, IDC_USECERTIFICATES_CHK, app.LocaleString (IDS_USECERTIFICATES_CHK, NULL)); - SetDlgItemText (hwnd, IDC_USEREFRESHDEVICES_CHK, app.LocaleString (IDS_USEREFRESHDEVICES_CHK, _r_fmt (L" (%s)", recommended.GetString ()))); + SetDlgItemText (hwnd, IDC_USENETWORKRESOLUTION_CHK, app.LocaleString (IDS_USENETWORKRESOLUTION_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_USECERTIFICATES_CHK, app.LocaleString (IDS_USECERTIFICATES_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_USEREFRESHDEVICES_CHK, app.LocaleString (IDS_USEREFRESHDEVICES_CHK, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); break; } case IDD_SETTINGS_BLOCKLIST: { - SetDlgItemText (hwnd, IDC_BLOCKLIST_SPY_DISABLE, app.LocaleString (IDS_DISABLE, NULL)); - SetDlgItemText (hwnd, IDC_BLOCKLIST_SPY_ALLOW, app.LocaleString (IDS_ACTION_ALLOW, NULL)); - SetDlgItemText (hwnd, IDC_BLOCKLIST_SPY_BLOCK, app.LocaleString (IDS_ACTION_BLOCK, _r_fmt (L" (%s)", recommended.GetString ()))); + SetDlgItemText (hwnd, IDC_BLOCKLIST_SPY_DISABLE, app.LocaleString (IDS_DISABLE, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_BLOCKLIST_SPY_ALLOW, app.LocaleString (IDS_ACTION_ALLOW, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_BLOCKLIST_SPY_BLOCK, app.LocaleString (IDS_ACTION_BLOCK, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); - SetDlgItemText (hwnd, IDC_BLOCKLIST_UPDATE_DISABLE, app.LocaleString (IDS_DISABLE, _r_fmt (L" (%s)", recommended.GetString ()))); - SetDlgItemText (hwnd, IDC_BLOCKLIST_UPDATE_ALLOW, app.LocaleString (IDS_ACTION_ALLOW, NULL)); - SetDlgItemText (hwnd, IDC_BLOCKLIST_UPDATE_BLOCK, app.LocaleString (IDS_ACTION_BLOCK, NULL)); + SetDlgItemText (hwnd, IDC_BLOCKLIST_UPDATE_DISABLE, app.LocaleString (IDS_DISABLE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); + SetDlgItemText (hwnd, IDC_BLOCKLIST_UPDATE_ALLOW, app.LocaleString (IDS_ACTION_ALLOW, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_BLOCKLIST_UPDATE_BLOCK, app.LocaleString (IDS_ACTION_BLOCK, NULL).GetString ()); - SetDlgItemText (hwnd, IDC_BLOCKLIST_EXTRA_DISABLE, app.LocaleString (IDS_DISABLE, _r_fmt (L" (%s)", recommended.GetString ()))); - SetDlgItemText (hwnd, IDC_BLOCKLIST_EXTRA_ALLOW, app.LocaleString (IDS_ACTION_ALLOW, NULL)); - SetDlgItemText (hwnd, IDC_BLOCKLIST_EXTRA_BLOCK, app.LocaleString (IDS_ACTION_BLOCK, NULL)); + SetDlgItemText (hwnd, IDC_BLOCKLIST_EXTRA_DISABLE, app.LocaleString (IDS_DISABLE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()).GetString ()); + SetDlgItemText (hwnd, IDC_BLOCKLIST_EXTRA_ALLOW, app.LocaleString (IDS_ACTION_ALLOW, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_BLOCKLIST_EXTRA_BLOCK, app.LocaleString (IDS_ACTION_BLOCK, NULL).GetString ()); _r_ctrl_settext (hwnd, IDC_BLOCKLIST_INFO, L"Author: WindowsSpyBlocker - block spying and tracking on Windows systems.", WINDOWSSPYBLOCKER_URL, WINDOWSSPYBLOCKER_URL); @@ -853,9 +854,9 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam case IDD_SETTINGS_INTERFACE: { - SetDlgItemText (hwnd, IDC_CONFIRMEXIT_CHK, app.LocaleString (IDS_CONFIRMEXIT_CHK, NULL)); - SetDlgItemText (hwnd, IDC_CONFIRMEXITTIMER_CHK, app.LocaleString (IDS_CONFIRMEXITTIMER_CHK, NULL)); - SetDlgItemText (hwnd, IDC_CONFIRMLOGCLEAR_CHK, app.LocaleString (IDS_CONFIRMLOGCLEAR_CHK, NULL)); + SetDlgItemText (hwnd, IDC_CONFIRMEXIT_CHK, app.LocaleString (IDS_CONFIRMEXIT_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_CONFIRMEXITTIMER_CHK, app.LocaleString (IDS_CONFIRMEXITTIMER_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_CONFIRMLOGCLEAR_CHK, app.LocaleString (IDS_CONFIRMLOGCLEAR_CHK, NULL).GetString ()); break; } @@ -871,12 +872,12 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam if (ptr_clr) { _r_fastlock_acquireshared (&lock_checkbox); - _r_listview_setitem (hwnd, IDC_COLORS, i, 0, app.LocaleString (ptr_clr->locale_id, NULL)); + _r_listview_setitem (hwnd, IDC_COLORS, i, 0, app.LocaleString (ptr_clr->locale_id, NULL).GetString ()); _r_fastlock_releaseshared (&lock_checkbox); } } - SetDlgItemText (hwnd, IDC_COLORS_HINT, app.LocaleString (IDS_COLORS_HINT, NULL)); + SetDlgItemText (hwnd, IDC_COLORS_HINT, app.LocaleString (IDS_COLORS_HINT, NULL).GetString ()); break; } @@ -884,33 +885,33 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam case IDD_SETTINGS_NOTIFICATIONS: { - SetDlgItemText (hwnd, IDC_ENABLENOTIFICATIONS_CHK, app.LocaleString (IDS_ENABLENOTIFICATIONS_CHK, NULL)); - SetDlgItemText (hwnd, IDC_NOTIFICATIONSOUND_CHK, app.LocaleString (IDS_NOTIFICATIONSOUND_CHK, NULL)); - SetDlgItemText (hwnd, IDC_NOTIFICATIONONTRAY_CHK, app.LocaleString (IDS_NOTIFICATIONONTRAY_CHK, NULL)); + SetDlgItemText (hwnd, IDC_ENABLENOTIFICATIONS_CHK, app.LocaleString (IDS_ENABLENOTIFICATIONS_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_NOTIFICATIONSOUND_CHK, app.LocaleString (IDS_NOTIFICATIONSOUND_CHK, NULL).GetString ()); + SetDlgItemText (hwnd, IDC_NOTIFICATIONONTRAY_CHK, app.LocaleString (IDS_NOTIFICATIONONTRAY_CHK, NULL).GetString ()); - SetDlgItemText (hwnd, IDC_NOTIFICATIONTIMEOUT_HINT, app.LocaleString (IDS_NOTIFICATIONTIMEOUT_HINT, NULL)); + SetDlgItemText (hwnd, IDC_NOTIFICATIONTIMEOUT_HINT, app.LocaleString (IDS_NOTIFICATIONTIMEOUT_HINT, NULL).GetString ()); rstring exclude = app.LocaleString (IDS_TITLE_EXCLUDE, NULL); - SetDlgItemText (hwnd, IDC_EXCLUDEBLOCKLIST_CHK, _r_fmt (L"%s %s", exclude.GetString (), app.LocaleString (IDS_EXCLUDEBLOCKLIST_CHK, NULL).GetString ())); - SetDlgItemText (hwnd, IDC_EXCLUDECUSTOM_CHK, _r_fmt (L"%s %s", exclude.GetString (), app.LocaleString (IDS_EXCLUDECUSTOM_CHK, NULL).GetString ())); + SetDlgItemText (hwnd, IDC_EXCLUDEBLOCKLIST_CHK, _r_fmt (L"%s %s", exclude.GetString (), app.LocaleString (IDS_EXCLUDEBLOCKLIST_CHK, NULL).GetString ()).GetString ()); + SetDlgItemText (hwnd, IDC_EXCLUDECUSTOM_CHK, _r_fmt (L"%s %s", exclude.GetString (), app.LocaleString (IDS_EXCLUDECUSTOM_CHK, NULL).GetString ()).GetString ()); break; } case IDD_SETTINGS_LOGGING: { - SetDlgItemText (hwnd, IDC_ENABLELOG_CHK, app.LocaleString (IDS_ENABLELOG_CHK, NULL)); + SetDlgItemText (hwnd, IDC_ENABLELOG_CHK, app.LocaleString (IDS_ENABLELOG_CHK, NULL).GetString ()); - SetDlgItemText (hwnd, IDC_LOGVIEWER_HINT, app.LocaleString (IDS_LOGVIEWER_HINT, L":")); - SetDlgItemText (hwnd, IDC_LOGSIZELIMIT_HINT, app.LocaleString (IDS_LOGSIZELIMIT_HINT, NULL)); + SetDlgItemText (hwnd, IDC_LOGVIEWER_HINT, app.LocaleString (IDS_LOGVIEWER_HINT, L":").GetString ()); + SetDlgItemText (hwnd, IDC_LOGSIZELIMIT_HINT, app.LocaleString (IDS_LOGSIZELIMIT_HINT, NULL).GetString ()); - SetDlgItemText (hwnd, IDC_ENABLEUILOG_CHK, app.LocaleString (IDS_ENABLEUILOG_CHK, L" (session only)")); + SetDlgItemText (hwnd, IDC_ENABLEUILOG_CHK, app.LocaleString (IDS_ENABLEUILOG_CHK, L" (session only)").GetString ()); rstring exclude = app.LocaleString (IDS_TITLE_EXCLUDE, NULL); - SetDlgItemText (hwnd, IDC_EXCLUDESTEALTH_CHK, _r_fmt (L"%s %s", exclude.GetString (), app.LocaleString (IDS_EXCLUDESTEALTH_CHK, NULL).GetString ())); - SetDlgItemText (hwnd, IDC_EXCLUDECLASSIFYALLOW_CHK, _r_fmt (L"%s %s", exclude.GetString (), app.LocaleString (IDS_EXCLUDECLASSIFYALLOW_CHK, (_r_sys_validversion (6, 2) ? NULL : L" [win8+]")).GetString ())); + SetDlgItemText (hwnd, IDC_EXCLUDESTEALTH_CHK, _r_fmt (L"%s %s", exclude.GetString (), app.LocaleString (IDS_EXCLUDESTEALTH_CHK, NULL).GetString ()).GetString ()); + SetDlgItemText (hwnd, IDC_EXCLUDECLASSIFYALLOW_CHK, _r_fmt (L"%s %s", exclude.GetString (), app.LocaleString (IDS_EXCLUDECLASSIFYALLOW_CHK, (L" [win8+]")).GetString ()).GetString ()); _r_wnd_addstyle (hwnd, IDC_LOGPATH_BTN, app.IsClassicUI () ? WS_EX_STATICEDGE : 0, WS_EX_STATICEDGE, GWL_EXSTYLE); _r_wnd_addstyle (hwnd, IDC_LOGVIEWER_BTN, app.IsClassicUI () ? WS_EX_STATICEDGE : 0, WS_EX_STATICEDGE, GWL_EXSTYLE); @@ -952,22 +953,22 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam INT ctrl_id = GetDlgCtrlID ((HWND)(lpnmdi->hdr.idFrom)); if (ctrl_id == IDC_RULE_BLOCKOUTBOUND) - _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_RULE_BLOCKOUTBOUND, NULL)); + _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_RULE_BLOCKOUTBOUND, NULL).GetString ()); else if (ctrl_id == IDC_RULE_BLOCKINBOUND) - _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_RULE_BLOCKINBOUND, NULL)); + _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_RULE_BLOCKINBOUND, NULL).GetString ()); else if (ctrl_id == IDC_RULE_ALLOWLOOPBACK) - _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_RULE_ALLOWLOOPBACK_HINT, NULL)); + _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_RULE_ALLOWLOOPBACK_HINT, NULL).GetString ()); else if (ctrl_id == IDC_USESTEALTHMODE_CHK) - _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_USESTEALTHMODE_HINT, NULL)); + _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_USESTEALTHMODE_HINT, NULL).GetString ()); else if (ctrl_id == IDC_INSTALLBOOTTIMEFILTERS_CHK) - _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_INSTALLBOOTTIMEFILTERS_HINT, NULL)); + _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_INSTALLBOOTTIMEFILTERS_HINT, NULL).GetString ()); else if (ctrl_id == IDC_SECUREFILTERS_CHK) - _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_SECUREFILTERS_HINT, NULL)); + _r_str_copy (buffer, RTL_NUMBER_OF (buffer), app.LocaleString (IDS_SECUREFILTERS_HINT, NULL).GetString ()); if (!_r_str_isempty (buffer)) lpnmdi->lpszText = buffer; @@ -980,7 +981,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam { 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) { @@ -1020,7 +1021,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam { LPNMITEMACTIVATE lpnmlv = (LPNMITEMACTIVATE)lparam; - INT listview_id = PtrToInt ((LPVOID)lpnmlv->hdr.idFrom); + INT listview_id = PtrToInt ((PVOID)lpnmlv->hdr.idFrom); if (lpnmlv->iItem == INVALID_INT) break; @@ -1078,7 +1079,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam 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; @@ -1291,7 +1292,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam if (!logpath.IsEmpty ()) { - app.ConfigSetString (L"LogPath", _r_path_unexpand (logpath)); + app.ConfigSetString (L"LogPath", _r_path_unexpand (logpath.GetString ()).GetString ()); _app_loginit (app.ConfigGetBoolean (L"IsLogEnabled", FALSE)); } @@ -1306,7 +1307,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam WCHAR path[MAX_PATH] = {0}; GetDlgItemText (hwnd, IDC_LOGPATH, path, RTL_NUMBER_OF (path)); - _r_str_copy (path, RTL_NUMBER_OF (path), _r_path_expand (path)); + _r_str_copy (path, RTL_NUMBER_OF (path), _r_path_expand (path).GetString ()); ofn.lStructSize = sizeof (ofn); ofn.hwndOwner = hwnd; @@ -1319,7 +1320,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam if (GetSaveFileName (&ofn)) { - _r_str_copy (path, RTL_NUMBER_OF (path), _r_path_unexpand (path)); + _r_str_copy (path, RTL_NUMBER_OF (path), _r_path_unexpand (path).GetString ()); app.ConfigSetString (L"LogPath", path); SetDlgItemText (hwnd, IDC_LOGPATH, path); @@ -1337,7 +1338,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam rstring logviewer = _r_ctrl_gettext (hwnd, ctrl_id); if (!logviewer.IsEmpty ()) - app.ConfigSetString (L"LogViewer", _r_path_unexpand (logviewer)); + app.ConfigSetString (L"LogViewer", _r_path_unexpand (logviewer.GetString ()).GetString ()); } break; @@ -1349,7 +1350,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam WCHAR path[MAX_PATH] = {0}; GetDlgItemText (hwnd, IDC_LOGVIEWER, path, RTL_NUMBER_OF (path)); - _r_str_copy (path, RTL_NUMBER_OF (path), _r_path_expand (path)); + _r_str_copy (path, RTL_NUMBER_OF (path), _r_path_expand (path).GetString ()); ofn.lStructSize = sizeof (ofn); ofn.hwndOwner = hwnd; @@ -1362,7 +1363,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam if (GetOpenFileName (&ofn)) { - _r_str_copy (path, RTL_NUMBER_OF (path), _r_path_unexpand (path)); + _r_str_copy (path, RTL_NUMBER_OF (path), _r_path_unexpand (path).GetString ()); app.ConfigSetString (L"LogViewer", path); SetDlgItemText (hwnd, IDC_LOGVIEWER, path); @@ -1506,14 +1507,14 @@ VOID _app_imagelist_init (HWND hwnd) SAFE_DELETE_ICON (config.hicon_package); // get default icon for executable - _app_getfileicon (_r_path_expand (PATH_NTOSKRNL), FALSE, &config.icon_id, &config.hicon_large); - _app_getfileicon (_r_path_expand (PATH_NTOSKRNL), TRUE, NULL, &config.hicon_small); - _app_getfileicon (_r_path_expand (PATH_SHELL32), FALSE, &config.icon_service_id, NULL); + _app_getfileicon (_r_path_expand (PATH_NTOSKRNL).GetString (), FALSE, &config.icon_id, &config.hicon_large); + _app_getfileicon (_r_path_expand (PATH_NTOSKRNL).GetString (), TRUE, NULL, &config.hicon_small); + _app_getfileicon (_r_path_expand (PATH_SHELL32).GetString (), FALSE, &config.icon_service_id, NULL); // get default icon for windows store package (win8+) if (_r_sys_validversion (6, 2)) { - if (!_app_getfileicon (_r_path_expand (PATH_WINSTORE), TRUE, &config.icon_uwp_id, &config.hicon_package)) + if (!_app_getfileicon (_r_path_expand (PATH_WINSTORE).GetString (), TRUE, &config.icon_uwp_id, &config.hicon_package)) { config.icon_uwp_id = config.icon_id; config.hicon_package = CopyIcon (config.hicon_small); @@ -1653,35 +1654,35 @@ VOID _app_tabs_init (HWND hwnd) INT tabs_count = 0; CreateWindowEx (0, WC_LISTVIEW, NULL, listview_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_APPS_PROFILE, hinst, NULL); - _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TAB_APPS, NULL), I_IMAGENONE, IDC_APPS_PROFILE); + _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TAB_APPS, NULL).GetString (), I_IMAGENONE, IDC_APPS_PROFILE); CreateWindowEx (0, WC_LISTVIEW, NULL, listview_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_APPS_SERVICE, hinst, NULL); - _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TAB_SERVICES, NULL), I_IMAGENONE, IDC_APPS_SERVICE); + _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TAB_SERVICES, NULL).GetString (), I_IMAGENONE, IDC_APPS_SERVICE); // uwp apps (win8+) if (_r_sys_validversion (6, 2)) { CreateWindowEx (0, WC_LISTVIEW, NULL, listview_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_APPS_UWP, hinst, NULL); - _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TAB_PACKAGES, NULL), I_IMAGENONE, IDC_APPS_UWP); + _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TAB_PACKAGES, NULL).GetString (), I_IMAGENONE, IDC_APPS_UWP); } if (!app.ConfigGetBoolean (L"IsInternalRulesDisabled", FALSE)) { CreateWindowEx (0, WC_LISTVIEW, NULL, listview_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_RULES_BLOCKLIST, hinst, NULL); - _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TRAY_BLOCKLIST_RULES, NULL), I_IMAGENONE, IDC_RULES_BLOCKLIST); + _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TRAY_BLOCKLIST_RULES, NULL).GetString (), I_IMAGENONE, IDC_RULES_BLOCKLIST); CreateWindowEx (0, WC_LISTVIEW, NULL, listview_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_RULES_SYSTEM, hinst, NULL); - _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TRAY_SYSTEM_RULES, NULL), I_IMAGENONE, IDC_RULES_SYSTEM); + _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TRAY_SYSTEM_RULES, NULL).GetString (), I_IMAGENONE, IDC_RULES_SYSTEM); } CreateWindowEx (0, WC_LISTVIEW, NULL, listview_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_RULES_CUSTOM, hinst, NULL); - _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TRAY_USER_RULES, NULL), I_IMAGENONE, IDC_RULES_CUSTOM); + _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TRAY_USER_RULES, NULL).GetString (), I_IMAGENONE, IDC_RULES_CUSTOM); CreateWindowEx (0, WC_LISTVIEW, NULL, listview_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_NETWORK, hinst, NULL); - _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TAB_NETWORK, NULL), I_IMAGENONE, IDC_NETWORK); + _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TAB_NETWORK, NULL).GetString (), I_IMAGENONE, IDC_NETWORK); CreateWindowEx (0, WC_LISTVIEW, NULL, listview_style | LVS_NOSORTHEADER, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_LOG, hinst, NULL); - _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TITLE_LOGGING, NULL), I_IMAGENONE, IDC_LOG); + _r_tab_additem (hwnd, IDC_TAB, tabs_count++, app.LocaleString (IDS_TITLE_LOGGING, NULL).GetString (), I_IMAGENONE, IDC_LOG); for (INT i = 0; i < tabs_count; i++) { @@ -1703,14 +1704,14 @@ VOID _app_tabs_init (HWND hwnd) if (listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP) { - _r_listview_addcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL), 0, LVCFMT_LEFT); - _r_listview_addcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_ADDED, NULL), 0, LVCFMT_RIGHT); + _r_listview_addcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL).GetString (), 0, LVCFMT_LEFT); + _r_listview_addcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_ADDED, NULL).GetString (), 0, LVCFMT_RIGHT); } else { - _r_listview_addcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL), 0, LVCFMT_LEFT); - _r_listview_addcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_PROTOCOL, NULL), 0, LVCFMT_RIGHT); - _r_listview_addcolumn (hwnd, listview_id, 2, app.LocaleString (IDS_DIRECTION, NULL), 0, LVCFMT_RIGHT); + _r_listview_addcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL).GetString (), 0, LVCFMT_LEFT); + _r_listview_addcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_PROTOCOL, NULL).GetString (), 0, LVCFMT_RIGHT); + _r_listview_addcolumn (hwnd, listview_id, 2, app.LocaleString (IDS_DIRECTION, NULL).GetString (), 0, LVCFMT_RIGHT); } _r_listview_addgroup (hwnd, listview_id, 0, L"", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE); @@ -1721,22 +1722,22 @@ VOID _app_tabs_init (HWND hwnd) { _r_listview_setstyle (hwnd, listview_id, listview_ex_style & ~LVS_EX_CHECKBOXES, FALSE); // no checkboxes - _r_listview_addcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL), 0, LVCFMT_LEFT); - _r_listview_addcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL)), 0, LVCFMT_LEFT); - _r_listview_addcolumn (hwnd, listview_id, 2, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL)), 0, LVCFMT_RIGHT); - _r_listview_addcolumn (hwnd, listview_id, 3, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE)), 0, LVCFMT_LEFT); - _r_listview_addcolumn (hwnd, listview_id, 4, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE)), 0, LVCFMT_RIGHT); - _r_listview_addcolumn (hwnd, listview_id, 5, app.LocaleString (IDS_PROTOCOL, NULL), 0, LVCFMT_RIGHT); + _r_listview_addcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL).GetString (), 0, LVCFMT_LEFT); + _r_listview_addcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL).GetString ()).GetString (), 0, LVCFMT_LEFT); + _r_listview_addcolumn (hwnd, listview_id, 2, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL).GetString ()).GetString (), 0, LVCFMT_RIGHT); + _r_listview_addcolumn (hwnd, listview_id, 3, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE).GetString ()).GetString (), 0, LVCFMT_LEFT); + _r_listview_addcolumn (hwnd, listview_id, 4, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE).GetString ()).GetString (), 0, LVCFMT_RIGHT); + _r_listview_addcolumn (hwnd, listview_id, 5, app.LocaleString (IDS_PROTOCOL, NULL).GetString (), 0, LVCFMT_RIGHT); if (listview_id == IDC_NETWORK) { - _r_listview_addcolumn (hwnd, listview_id, 6, app.LocaleString (IDS_STATE, NULL), 0, LVCFMT_RIGHT); + _r_listview_addcolumn (hwnd, listview_id, 6, app.LocaleString (IDS_STATE, NULL).GetString (), 0, LVCFMT_RIGHT); } else if (listview_id == IDC_LOG) { - _r_listview_addcolumn (hwnd, listview_id, 6, app.LocaleString (IDS_FILTER, NULL), 0, LVCFMT_LEFT); - _r_listview_addcolumn (hwnd, listview_id, 7, app.LocaleString (IDS_DIRECTION, NULL), 0, LVCFMT_RIGHT); - _r_listview_addcolumn (hwnd, listview_id, 8, app.LocaleString (IDS_STATE, NULL), 0, LVCFMT_RIGHT); + _r_listview_addcolumn (hwnd, listview_id, 6, app.LocaleString (IDS_FILTER, NULL).GetString (), 0, LVCFMT_LEFT); + _r_listview_addcolumn (hwnd, listview_id, 7, app.LocaleString (IDS_DIRECTION, NULL).GetString (), 0, LVCFMT_RIGHT); + _r_listview_addcolumn (hwnd, listview_id, 8, app.LocaleString (IDS_STATE, NULL).GetString (), 0, LVCFMT_RIGHT); } } @@ -1746,7 +1747,7 @@ VOID _app_tabs_init (HWND hwnd) } } -LPVOID allocate_pugixml (size_t size) +PVOID allocate_pugixml (size_t size) { return _r_mem_allocatezero (size); } @@ -1784,10 +1785,10 @@ VOID _app_initialize () _r_str_printf (config.profile_path, RTL_NUMBER_OF (config.profile_path), L"%s\\" XML_PROFILE, app.GetProfileDirectory ()); _r_str_printf (config.profile_internal_path, RTL_NUMBER_OF (config.profile_internal_path), L"%s\\" XML_PROFILE_INTERNAL, app.GetProfileDirectory ()); - _r_str_copy (config.profile_path_backup, RTL_NUMBER_OF (config.profile_path_backup), _r_fmt (L"%s.bak", config.profile_path)); + _r_str_copy (config.profile_path_backup, RTL_NUMBER_OF (config.profile_path_backup), _r_fmt (L"%s.bak", config.profile_path).GetString ()); config.ntoskrnl_hash = _r_str_hash (PROC_SYSTEM_NAME); - config.svchost_hash = _r_str_hash (_r_path_expand (PATH_SVCHOST)); + config.svchost_hash = _r_str_hash (_r_path_expand (PATH_SVCHOST).GetString ()); config.my_hash = _r_str_hash (app.GetBinaryPath ()); // initialize timers @@ -1799,14 +1800,13 @@ VOID _app_initialize () timers.clear (); - timers.push_back (_R_SECONDSCLOCK_MIN (2)); - timers.push_back (_R_SECONDSCLOCK_MIN (5)); - timers.push_back (_R_SECONDSCLOCK_MIN (10)); - timers.push_back (_R_SECONDSCLOCK_MIN (30)); - timers.push_back (_R_SECONDSCLOCK_HOUR (1)); - timers.push_back (_R_SECONDSCLOCK_HOUR (2)); - timers.push_back (_R_SECONDSCLOCK_HOUR (4)); - timers.push_back (_R_SECONDSCLOCK_HOUR (6)); + timers.push_back (_r_calc_minutes2seconds (time_t, 2)); + timers.push_back (_r_calc_minutes2seconds (time_t, 5)); + timers.push_back (_r_calc_minutes2seconds (time_t, 10)); + timers.push_back (_r_calc_hours2seconds (time_t, 1)); + timers.push_back (_r_calc_hours2seconds (time_t, 2)); + timers.push_back (_r_calc_hours2seconds (time_t, 4)); + timers.push_back (_r_calc_hours2seconds (time_t, 6)); } // initialize thread objects @@ -1869,7 +1869,7 @@ find_wrap: if (item_text.IsEmpty ()) continue; - if (StrStrNIW (item_text, lpfr->lpstrFindWhat, (UINT)item_text.GetLength ()) != NULL) + if (StrStrNIW (item_text.GetString (), lpfr->lpstrFindWhat, (UINT)item_text.GetLength ()) != NULL) { _app_showitem (hwnd, listview_id, current_item, INVALID_INT); return FALSE; @@ -1951,7 +1951,7 @@ find_wrap: // add blocklist to update if (!app.ConfigGetBoolean (L"IsInternalRulesDisabled", FALSE)) - app.UpdateAddComponent (L"Internal rules", L"profile_internal", _r_fmt (L"%" TEXT (PR_LONG64), config.profile_internal_timestamp), config.profile_internal_path, FALSE); + app.UpdateAddComponent (L"Internal rules", L"profile_internal", _r_fmt (L"%" TEXT (PR_LONG64), config.profile_internal_timestamp).GetString (), config.profile_internal_path, FALSE); // initialize tab _app_settab_id (hwnd, app.ConfigGetInteger (L"CurrentTab", IDC_APPS_PROFILE)); @@ -1964,7 +1964,7 @@ find_wrap: _app_notifycreatewindow (); // create network monitor thread - _r_sys_createthreadex (&NetworkMonitorThread, (LPVOID)hwnd, FALSE, THREAD_PRIORITY_LOWEST); + _r_sys_createthreadex (&NetworkMonitorThread, (PVOID)hwnd, FALSE, THREAD_PRIORITY_LOWEST); // install filters { @@ -1982,7 +1982,7 @@ find_wrap: } else { - _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 ()); } } @@ -2147,18 +2147,18 @@ find_wrap: _r_menu_enableitem (hmenu, IDM_SECURITY_TITLE, MF_BYCOMMAND, FALSE); _r_menu_enableitem (hmenu, IDM_ADVANCED_TITLE, MF_BYCOMMAND, FALSE); - app.LocaleMenu (hmenu, IDS_RULE_BLOCKOUTBOUND, IDM_RULE_BLOCKOUTBOUND, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); - app.LocaleMenu (hmenu, IDS_RULE_BLOCKINBOUND, IDM_RULE_BLOCKINBOUND, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); - app.LocaleMenu (hmenu, IDS_RULE_ALLOWLOOPBACK, IDM_RULE_ALLOWLOOPBACK, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); - app.LocaleMenu (hmenu, IDS_RULE_ALLOW6TO4, IDM_RULE_ALLOW6TO4, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); + app.LocaleMenu (hmenu, IDS_RULE_BLOCKOUTBOUND, IDM_RULE_BLOCKOUTBOUND, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); + app.LocaleMenu (hmenu, IDS_RULE_BLOCKINBOUND, IDM_RULE_BLOCKINBOUND, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); + app.LocaleMenu (hmenu, IDS_RULE_ALLOWLOOPBACK, IDM_RULE_ALLOWLOOPBACK, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); + app.LocaleMenu (hmenu, IDS_RULE_ALLOW6TO4, IDM_RULE_ALLOW6TO4, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); - app.LocaleMenu (hmenu, IDS_SECUREFILTERS_CHK, IDM_SECUREFILTERS_CHK, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); - app.LocaleMenu (hmenu, IDS_USESTEALTHMODE_CHK, IDM_USESTEALTHMODE_CHK, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); - app.LocaleMenu (hmenu, IDS_INSTALLBOOTTIMEFILTERS_CHK, IDM_INSTALLBOOTTIMEFILTERS_CHK, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); + app.LocaleMenu (hmenu, IDS_SECUREFILTERS_CHK, IDM_SECUREFILTERS_CHK, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); + app.LocaleMenu (hmenu, IDS_USESTEALTHMODE_CHK, IDM_USESTEALTHMODE_CHK, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); + app.LocaleMenu (hmenu, IDS_INSTALLBOOTTIMEFILTERS_CHK, IDM_INSTALLBOOTTIMEFILTERS_CHK, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); app.LocaleMenu (hmenu, IDS_USENETWORKRESOLUTION_CHK, IDM_USENETWORKRESOLUTION_CHK, FALSE, NULL); app.LocaleMenu (hmenu, IDS_USECERTIFICATES_CHK, IDM_USECERTIFICATES_CHK, FALSE, NULL); - app.LocaleMenu (hmenu, IDS_USEREFRESHDEVICES_CHK, IDM_USEREFRESHDEVICES_CHK, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); + app.LocaleMenu (hmenu, IDS_USEREFRESHDEVICES_CHK, IDM_USEREFRESHDEVICES_CHK, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); app.LocaleMenu (hmenu, IDS_TRAY_BLOCKLIST_RULES, 4, TRUE, NULL); @@ -2172,13 +2172,13 @@ find_wrap: app.LocaleMenu (hmenu, IDS_DISABLE, IDM_BLOCKLIST_SPY_DISABLE, FALSE, NULL); app.LocaleMenu (hmenu, IDS_ACTION_ALLOW, IDM_BLOCKLIST_SPY_ALLOW, FALSE, NULL); - app.LocaleMenu (hmenu, IDS_ACTION_BLOCK, IDM_BLOCKLIST_SPY_BLOCK, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); + app.LocaleMenu (hmenu, IDS_ACTION_BLOCK, IDM_BLOCKLIST_SPY_BLOCK, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); - app.LocaleMenu (hmenu, IDS_DISABLE, IDM_BLOCKLIST_UPDATE_DISABLE, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); + app.LocaleMenu (hmenu, IDS_DISABLE, IDM_BLOCKLIST_UPDATE_DISABLE, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); app.LocaleMenu (hmenu, IDS_ACTION_ALLOW, IDM_BLOCKLIST_UPDATE_ALLOW, FALSE, NULL); app.LocaleMenu (hmenu, IDS_ACTION_BLOCK, IDM_BLOCKLIST_UPDATE_BLOCK, FALSE, NULL); - app.LocaleMenu (hmenu, IDS_DISABLE, IDM_BLOCKLIST_EXTRA_DISABLE, FALSE, _r_fmt (L" (%s)", recommended.GetString ())); + app.LocaleMenu (hmenu, IDS_DISABLE, IDM_BLOCKLIST_EXTRA_DISABLE, FALSE, _r_fmt (L" (%s)", recommended.GetString ()).GetString ()); app.LocaleMenu (hmenu, IDS_ACTION_ALLOW, IDM_BLOCKLIST_EXTRA_ALLOW, FALSE, NULL); app.LocaleMenu (hmenu, IDS_ACTION_BLOCK, IDM_BLOCKLIST_EXTRA_BLOCK, FALSE, NULL); @@ -2193,19 +2193,19 @@ find_wrap: // localize toolbar _app_setinterfacestate (hwnd); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_REFRESH, app.LocaleString (IDS_REFRESH, NULL), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_SETTINGS, app.LocaleString (IDS_SETTINGS, NULL), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_REFRESH, app.LocaleString (IDS_REFRESH, NULL).GetString (), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_SETTINGS, app.LocaleString (IDS_SETTINGS, NULL).GetString (), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_OPENRULESEDITOR, app.LocaleString (IDS_OPENRULESEDITOR, L"..."), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_OPENRULESEDITOR, app.LocaleString (IDS_OPENRULESEDITOR, L"...").GetString (), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLENOTIFICATIONS_CHK, app.LocaleString (IDS_ENABLENOTIFICATIONS_CHK, NULL), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLELOG_CHK, app.LocaleString (IDS_ENABLELOG_CHK, NULL), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLEUILOG_CHK, app.LocaleString (IDS_ENABLEUILOG_CHK, L" (session only)"), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLENOTIFICATIONS_CHK, app.LocaleString (IDS_ENABLENOTIFICATIONS_CHK, NULL).GetString (), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLELOG_CHK, app.LocaleString (IDS_ENABLELOG_CHK, NULL).GetString (), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLEUILOG_CHK, app.LocaleString (IDS_ENABLEUILOG_CHK, L" (session only)").GetString (), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGSHOW, app.LocaleString (IDS_LOGSHOW, L" (Ctrl+I)"), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGCLEAR, app.LocaleString (IDS_LOGCLEAR, L" (Ctrl+X)"), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGSHOW, app.LocaleString (IDS_LOGSHOW, L" (Ctrl+I)").GetString (), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGCLEAR, app.LocaleString (IDS_LOGCLEAR, L" (Ctrl+X)").GetString (), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_DONATE, app.LocaleString (IDS_DONATE, NULL), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_DONATE, app.LocaleString (IDS_DONATE, NULL).GetString (), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); // set rebar size _app_toolbar_resize (); @@ -2244,40 +2244,40 @@ find_wrap: else continue; - _r_tab_setitem (hwnd, IDC_TAB, i, app.LocaleString (locale_id, NULL), I_IMAGENONE, 0); + _r_tab_setitem (hwnd, IDC_TAB, i, app.LocaleString (locale_id, NULL).GetString (), I_IMAGENONE, 0); if (listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP) { - _r_listview_setcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL), 0); - _r_listview_setcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_ADDED, NULL), 0); + _r_listview_setcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_ADDED, NULL).GetString (), 0); } else if (listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM) { - _r_listview_setcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL), 0); - _r_listview_setcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_PROTOCOL, NULL), 0); - _r_listview_setcolumn (hwnd, listview_id, 2, app.LocaleString (IDS_DIRECTION, NULL), 0); + _r_listview_setcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_PROTOCOL, NULL).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 2, app.LocaleString (IDS_DIRECTION, NULL).GetString (), 0); } else if (listview_id == IDC_NETWORK) { - _r_listview_setcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL), 0); - _r_listview_setcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL)), 0); - _r_listview_setcolumn (hwnd, listview_id, 2, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL)), 0); - _r_listview_setcolumn (hwnd, listview_id, 3, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE)), 0); - _r_listview_setcolumn (hwnd, listview_id, 4, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE)), 0); - _r_listview_setcolumn (hwnd, listview_id, 5, app.LocaleString (IDS_PROTOCOL, NULL), 0); - _r_listview_setcolumn (hwnd, listview_id, 6, app.LocaleString (IDS_STATE, NULL), 0); + _r_listview_setcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL).GetString ()).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 2, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL).GetString ()).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 3, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE).GetString ()).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 4, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE).GetString ()).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 5, app.LocaleString (IDS_PROTOCOL, NULL).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 6, app.LocaleString (IDS_STATE, NULL).GetString (), 0); } else if (listview_id == IDC_LOG) { - _r_listview_setcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL), 0); - _r_listview_setcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL)), 0); - _r_listview_setcolumn (hwnd, listview_id, 2, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL)), 0); - _r_listview_setcolumn (hwnd, listview_id, 3, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE)), 0); - _r_listview_setcolumn (hwnd, listview_id, 4, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE)), 0); - _r_listview_setcolumn (hwnd, listview_id, 5, app.LocaleString (IDS_PROTOCOL, NULL), 0); - _r_listview_setcolumn (hwnd, listview_id, 6, app.LocaleString (IDS_FILTER, NULL), 0); - _r_listview_setcolumn (hwnd, listview_id, 7, app.LocaleString (IDS_DIRECTION, NULL), 0); - _r_listview_setcolumn (hwnd, listview_id, 8, app.LocaleString (IDS_STATE, NULL), 0); + _r_listview_setcolumn (hwnd, listview_id, 0, app.LocaleString (IDS_NAME, NULL).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 1, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL).GetString ()).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 2, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_LOCAL).GetString ()).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 3, app.LocaleString (IDS_ADDRESS, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE).GetString ()).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 4, app.LocaleString (IDS_PORT, _r_fmt (L" (%s)", SZ_DIRECTION_REMOTE).GetString ()).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 5, app.LocaleString (IDS_PROTOCOL, NULL).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 6, app.LocaleString (IDS_FILTER, NULL).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 7, app.LocaleString (IDS_DIRECTION, NULL).GetString (), 0); + _r_listview_setcolumn (hwnd, listview_id, 8, app.LocaleString (IDS_STATE, NULL).GetString (), 0); } SendDlgItemMessage (hwnd, listview_id, LVM_RESETEMPTYTEXT, 0, 0); @@ -2320,19 +2320,19 @@ find_wrap: // reset toolbar information _app_setinterfacestate (hwnd); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_REFRESH, app.LocaleString (IDS_REFRESH, NULL), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_SETTINGS, app.LocaleString (IDS_SETTINGS, NULL), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_REFRESH, app.LocaleString (IDS_REFRESH, NULL).GetString (), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_SETTINGS, app.LocaleString (IDS_SETTINGS, NULL).GetString (), BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_OPENRULESEDITOR, app.LocaleString (IDS_OPENRULESEDITOR, L"..."), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_OPENRULESEDITOR, app.LocaleString (IDS_OPENRULESEDITOR, L"...").GetString (), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLENOTIFICATIONS_CHK, app.LocaleString (IDS_ENABLENOTIFICATIONS_CHK, NULL), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLELOG_CHK, app.LocaleString (IDS_ENABLELOG_CHK, NULL), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLEUILOG_CHK, app.LocaleString (IDS_ENABLEUILOG_CHK, NULL), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLENOTIFICATIONS_CHK, app.LocaleString (IDS_ENABLENOTIFICATIONS_CHK, NULL).GetString (), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLELOG_CHK, app.LocaleString (IDS_ENABLELOG_CHK, NULL).GetString (), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLEUILOG_CHK, app.LocaleString (IDS_ENABLEUILOG_CHK, NULL).GetString (), BTNS_CHECK | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGSHOW, app.LocaleString (IDS_LOGSHOW, L" (Ctrl+I)"), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGCLEAR, app.LocaleString (IDS_LOGCLEAR, L" (Ctrl+X)"), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGSHOW, app.LocaleString (IDS_LOGSHOW, L" (Ctrl+I)").GetString (), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_LOGCLEAR, app.LocaleString (IDS_LOGCLEAR, L" (Ctrl+X)").GetString (), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); - _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_DONATE, app.LocaleString (IDS_DONATE, NULL), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); + _r_toolbar_setbutton (config.hrebar, IDC_TOOLBAR, IDM_DONATE, app.LocaleString (IDS_DONATE, NULL).GetString (), BTNS_BUTTON | BTNS_AUTOSIZE, 0, I_IMAGENONE); _app_toolbar_resize (); @@ -2387,8 +2387,8 @@ find_wrap: if (_wfp_isfiltersinstalled ()) { if (_app_istimersactive () ? - !app.ShowConfirmMessage (hwnd, NULL, app.LocaleString (IDS_QUESTION_TIMER, NULL), L"ConfirmExitTimer") : - !app.ShowConfirmMessage (hwnd, NULL, app.LocaleString (IDS_QUESTION_EXIT, NULL), L"ConfirmExit2")) + !app.ShowConfirmMessage (hwnd, NULL, app.LocaleString (IDS_QUESTION_TIMER, NULL).GetString (), L"ConfirmExitTimer") : + !app.ShowConfirmMessage (hwnd, NULL, app.LocaleString (IDS_QUESTION_EXIT, NULL).GetString (), L"ConfirmExit2")) { SetWindowLongPtr (hwnd, DWLP_MSGRESULT, TRUE); return TRUE; @@ -2542,7 +2542,7 @@ find_wrap: LONG_PTR result = CDRF_DODEFAULT; LPNMLVCUSTOMDRAW lpnmcd = (LPNMLVCUSTOMDRAW)lparam; - INT ctrl_id = PtrToInt ((LPVOID)lpnmcd->nmcd.hdr.idFrom); + INT ctrl_id = PtrToInt ((PVOID)lpnmcd->nmcd.hdr.idFrom); if (ctrl_id == IDC_TOOLBAR) { @@ -2561,7 +2561,7 @@ find_wrap: { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lparam; - INT ctrl_id = PtrToInt ((LPVOID)lpnmlv->hdr.idFrom); + INT ctrl_id = PtrToInt ((PVOID)lpnmlv->hdr.idFrom); _app_listviewsort (hwnd, ctrl_id, lpnmlv->iSubItem, TRUE); @@ -2572,7 +2572,7 @@ find_wrap: { 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; } @@ -2588,7 +2588,7 @@ find_wrap: if (_r_fastlock_islocked (&lock_checkbox)) break; - INT listview_id = PtrToInt ((LPVOID)lpnmlv->hdr.idFrom); + INT listview_id = PtrToInt ((PVOID)lpnmlv->hdr.idFrom); BOOLEAN is_changed = FALSE; BOOLEAN is_enabled = (lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (2); @@ -2689,7 +2689,7 @@ find_wrap: 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; @@ -2703,7 +2703,7 @@ find_wrap: 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_APPS_PROFILE && ctrl_id <= IDC_LOG) { @@ -2736,7 +2736,7 @@ find_wrap: if (lpnmlv->iItem == INVALID_INT) break; - INT listview_id = PtrToInt ((LPVOID)lpnmlv->hdr.idFrom); + INT listview_id = PtrToInt ((PVOID)lpnmlv->hdr.idFrom); if (!(listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_LOG)) break; @@ -2758,30 +2758,30 @@ find_wrap: hsubmenu2 = CreatePopupMenu (); // show rules - AppendMenu (hsubmenu1, MF_STRING, IDM_DISABLENOTIFICATIONS, app.LocaleString (IDS_DISABLENOTIFICATIONS, NULL)); + AppendMenu (hsubmenu1, MF_STRING, IDM_DISABLENOTIFICATIONS, app.LocaleString (IDS_DISABLENOTIFICATIONS, NULL).GetString ()); _app_generate_rulesmenu (hsubmenu1, hash_item); // show timers - AppendMenu (hsubmenu2, MF_STRING, IDM_DISABLETIMER, app.LocaleString (IDS_DISABLETIMER, NULL)); + AppendMenu (hsubmenu2, MF_STRING, IDM_DISABLETIMER, app.LocaleString (IDS_DISABLETIMER, NULL).GetString ()); AppendMenu (hsubmenu2, MF_SEPARATOR, 0, NULL); _app_generate_timermenu (hsubmenu2, hash_item); - AppendMenu (hmenu, MF_STRING, IDM_PROPERTIES, app.LocaleString (IDS_EXPLORE, L"\tEnter")); + AppendMenu (hmenu, MF_STRING, IDM_PROPERTIES, app.LocaleString (IDS_EXPLORE, L"\tEnter").GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_POPUP, (UINT_PTR)hsubmenu1, app.LocaleString (IDS_TRAY_RULES, NULL)); - AppendMenu (hmenu, MF_POPUP, (UINT_PTR)hsubmenu2, app.LocaleString (IDS_TIMER, NULL)); + AppendMenu (hmenu, MF_POPUP, (UINT_PTR)hsubmenu1, app.LocaleString (IDS_TRAY_RULES, NULL).GetString ()); + AppendMenu (hmenu, MF_POPUP, (UINT_PTR)hsubmenu2, app.LocaleString (IDS_TIMER, NULL).GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_DELETE, app.LocaleString (IDS_DELETE, L"\tDel")); + AppendMenu (hmenu, MF_STRING, IDM_DELETE, app.LocaleString (IDS_DELETE, L"\tDel").GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_CHECK, app.LocaleString (IDS_CHECK, NULL)); - AppendMenu (hmenu, MF_STRING, IDM_UNCHECK, app.LocaleString (IDS_UNCHECK, NULL)); + AppendMenu (hmenu, MF_STRING, IDM_CHECK, app.LocaleString (IDS_CHECK, NULL).GetString ()); + AppendMenu (hmenu, MF_STRING, IDM_UNCHECK, app.LocaleString (IDS_UNCHECK, NULL).GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_SELECT_ALL, app.LocaleString (IDS_SELECT_ALL, L"\tCtrl+A")); + AppendMenu (hmenu, MF_STRING, IDM_SELECT_ALL, app.LocaleString (IDS_SELECT_ALL, L"\tCtrl+A").GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, L"\tCtrl+C")); - AppendMenu (hmenu, MF_STRING, IDM_COPY2, app.LocaleString (IDS_COPY, _r_fmt (L" \"%s\"", _r_listview_getcolumntext (hwnd, listview_id, lv_column_current).GetString ()))); + AppendMenu (hmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, L"\tCtrl+C").GetString ()); + AppendMenu (hmenu, MF_STRING, IDM_COPY2, app.LocaleString (IDS_COPY, _r_fmt (L" \"%s\"", _r_listview_getcolumntext (hwnd, listview_id, lv_column_current).GetString ()).GetString ()).GetString ()); SetMenuDefaultItem (hmenu, IDM_PROPERTIES, MF_BYCOMMAND); @@ -2793,13 +2793,13 @@ find_wrap: else if (listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM) { if (listview_id == IDC_RULES_CUSTOM) - AppendMenu (hmenu, MF_STRING, IDM_OPENRULESEDITOR, app.LocaleString (IDS_ADD, L"...")); + AppendMenu (hmenu, MF_STRING, IDM_OPENRULESEDITOR, app.LocaleString (IDS_ADD, L"...").GetString ()); - AppendMenu (hmenu, MF_STRING, IDM_PROPERTIES, app.LocaleString (IDS_EDIT2, L"...\tEnter")); + AppendMenu (hmenu, MF_STRING, IDM_PROPERTIES, app.LocaleString (IDS_EDIT2, L"...\tEnter").GetString ()); if (listview_id == IDC_RULES_CUSTOM) { - AppendMenu (hmenu, MF_STRING, IDM_DELETE, app.LocaleString (IDS_DELETE, L"\tDel")); + AppendMenu (hmenu, MF_STRING, IDM_DELETE, app.LocaleString (IDS_DELETE, L"\tDel").GetString ()); PR_OBJECT ptr_rule_object = _app_getrulebyid (hash_item); @@ -2815,27 +2815,27 @@ find_wrap: } AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_CHECK, app.LocaleString (IDS_CHECK, NULL)); - AppendMenu (hmenu, MF_STRING, IDM_UNCHECK, app.LocaleString (IDS_UNCHECK, NULL)); + AppendMenu (hmenu, MF_STRING, IDM_CHECK, app.LocaleString (IDS_CHECK, NULL).GetString ()); + AppendMenu (hmenu, MF_STRING, IDM_UNCHECK, app.LocaleString (IDS_UNCHECK, NULL).GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_SELECT_ALL, app.LocaleString (IDS_SELECT_ALL, L"\tCtrl+A")); + AppendMenu (hmenu, MF_STRING, IDM_SELECT_ALL, app.LocaleString (IDS_SELECT_ALL, L"\tCtrl+A").GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, L"\tCtrl+C")); - AppendMenu (hmenu, MF_STRING, IDM_COPY2, app.LocaleString (IDS_COPY, _r_fmt (L" \"%s\"", _r_listview_getcolumntext (hwnd, listview_id, lv_column_current).GetString ()))); + AppendMenu (hmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, L"\tCtrl+C").GetString ()); + AppendMenu (hmenu, MF_STRING, IDM_COPY2, app.LocaleString (IDS_COPY, _r_fmt (L" \"%s\"", _r_listview_getcolumntext (hwnd, listview_id, lv_column_current).GetString ()).GetString ()).GetString ()); SetMenuDefaultItem (hmenu, IDM_PROPERTIES, MF_BYCOMMAND); } else if (listview_id == IDC_NETWORK) { - AppendMenu (hmenu, MF_STRING, IDM_PROPERTIES, app.LocaleString (IDS_SHOWINLIST, L"\tEnter")); - AppendMenu (hmenu, MF_STRING, IDM_OPENRULESEDITOR, app.LocaleString (IDS_OPENRULESEDITOR, L"...")); + AppendMenu (hmenu, MF_STRING, IDM_PROPERTIES, app.LocaleString (IDS_SHOWINLIST, L"\tEnter").GetString ()); + AppendMenu (hmenu, MF_STRING, IDM_OPENRULESEDITOR, app.LocaleString (IDS_OPENRULESEDITOR, L"...").GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_NETWORK_CLOSE, app.LocaleString (IDS_NETWORK_CLOSE, NULL)); + AppendMenu (hmenu, MF_STRING, IDM_NETWORK_CLOSE, app.LocaleString (IDS_NETWORK_CLOSE, NULL).GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_SELECT_ALL, app.LocaleString (IDS_SELECT_ALL, L"\tCtrl+A")); + AppendMenu (hmenu, MF_STRING, IDM_SELECT_ALL, app.LocaleString (IDS_SELECT_ALL, L"\tCtrl+A").GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, L"\tCtrl+C")); - AppendMenu (hmenu, MF_STRING, IDM_COPY2, app.LocaleString (IDS_COPY, _r_fmt (L" \"%s\"", _r_listview_getcolumntext (hwnd, listview_id, lv_column_current).GetString ()))); + AppendMenu (hmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, L"\tCtrl+C").GetString ()); + AppendMenu (hmenu, MF_STRING, IDM_COPY2, app.LocaleString (IDS_COPY, _r_fmt (L" \"%s\"", _r_listview_getcolumntext (hwnd, listview_id, lv_column_current).GetString ()).GetString ()).GetString ()); SetMenuDefaultItem (hmenu, IDM_PROPERTIES, MF_BYCOMMAND); @@ -2852,14 +2852,14 @@ find_wrap: } else if (listview_id == IDC_LOG) { - AppendMenu (hmenu, MF_STRING, IDM_PROPERTIES, app.LocaleString (IDS_SHOWINLIST, L"\tEnter")); - AppendMenu (hmenu, MF_STRING, IDM_OPENRULESEDITOR, app.LocaleString (IDS_OPENRULESEDITOR, L"...")); - AppendMenu (hmenu, MF_STRING, IDM_TRAY_LOGCLEAR, app.LocaleString (IDS_LOGCLEAR, L"\tCtrl+X")); + AppendMenu (hmenu, MF_STRING, IDM_PROPERTIES, app.LocaleString (IDS_SHOWINLIST, L"\tEnter").GetString ()); + AppendMenu (hmenu, MF_STRING, IDM_OPENRULESEDITOR, app.LocaleString (IDS_OPENRULESEDITOR, L"...").GetString ()); + AppendMenu (hmenu, MF_STRING, IDM_TRAY_LOGCLEAR, app.LocaleString (IDS_LOGCLEAR, L"\tCtrl+X").GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_SELECT_ALL, app.LocaleString (IDS_SELECT_ALL, L"\tCtrl+A")); + AppendMenu (hmenu, MF_STRING, IDM_SELECT_ALL, app.LocaleString (IDS_SELECT_ALL, L"\tCtrl+A").GetString ()); AppendMenu (hmenu, MF_SEPARATOR, 0, NULL); - AppendMenu (hmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, L"\tCtrl+C")); - AppendMenu (hmenu, MF_STRING, IDM_COPY2, app.LocaleString (IDS_COPY, _r_fmt (L" \"%s\"", _r_listview_getcolumntext (hwnd, listview_id, lv_column_current).GetString ()))); + AppendMenu (hmenu, MF_STRING, IDM_COPY, app.LocaleString (IDS_COPY, L"\tCtrl+C").GetString ()); + AppendMenu (hmenu, MF_STRING, IDM_COPY2, app.LocaleString (IDS_COPY, _r_fmt (L" \"%s\"", _r_listview_getcolumntext (hwnd, listview_id, lv_column_current).GetString ()).GetString ()).GetString ()); SetMenuDefaultItem (hmenu, IDM_PROPERTIES, MF_BYCOMMAND); } @@ -3284,7 +3284,7 @@ find_wrap: case IDM_DONATE: { - ShellExecute (hwnd, NULL, _r_fmt (_APP_DONATE_URL, APP_NAME_SHORT), NULL, NULL, SW_SHOWDEFAULT); + ShellExecute (hwnd, NULL, _r_fmt (_APP_DONATE_URL, APP_NAME_SHORT).GetString (), NULL, NULL, SW_SHOWDEFAULT); break; } @@ -3599,7 +3599,7 @@ find_wrap: if (ChooseFont (&cf)) { - app.ConfigSetString (L"Font", !_r_str_isempty (lf.lfFaceName) ? _r_fmt (L"%s;%d;%d", lf.lfFaceName, _r_dc_fontheighttosize (hwnd, lf.lfHeight), lf.lfWeight) : UI_FONT_DEFAULT); + app.ConfigSetString (L"Font", !_r_str_isempty (lf.lfFaceName) ? _r_fmt (L"%s;%d;%d", lf.lfFaceName, _r_dc_fontheighttosize (hwnd, lf.lfHeight), lf.lfWeight).GetString () : UI_FONT_DEFAULT); SAFE_DELETE_OBJECT (config.hfont); @@ -3814,15 +3814,15 @@ find_wrap: } 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 ()); - if (!_r_fs_exists (path)) + if (!_r_fs_exists (path.GetString ())) return FALSE; if (_r_fs_isvalidhandle (config.hlogfile)) FlushFileBuffers (config.hlogfile); - _r_sys_createprocess (NULL, _r_fmt (L"%s \"%s\"", _app_getlogviewer ().GetString (), path.GetString ()), NULL); + _r_sys_createprocess (NULL, _r_fmt (L"%s \"%s\"", _app_getlogviewer ().GetString (), path.GetString ()).GetString (), NULL); } break; @@ -3830,12 +3830,12 @@ find_wrap: case IDM_TRAY_LOGCLEAR: { - 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 ()); BOOLEAN is_validhandle = _r_fs_isvalidhandle (config.hlogfile); - if (is_validhandle || _r_fs_exists (path) || !log_arr.empty ()) + if (is_validhandle || _r_fs_exists (path.GetString ()) || !log_arr.empty ()) { - if (!app.ShowConfirmMessage (hwnd, NULL, app.LocaleString (IDS_QUESTION, NULL), L"ConfirmLogClear")) + if (!app.ShowConfirmMessage (hwnd, NULL, app.LocaleString (IDS_QUESTION, NULL).GetString (), L"ConfirmLogClear")) break; _app_freelogstack (); @@ -3852,14 +3852,14 @@ find_wrap: LPCWSTR path = app.GetLogPath (); if (_r_fs_exists (path)) - _r_sys_createprocess (NULL, _r_fmt (L"%s \"%s\"", _app_getlogviewer ().GetString (), path), NULL); + _r_sys_createprocess (NULL, _r_fmt (L"%s \"%s\"", _app_getlogviewer ().GetString (), path).GetString (), NULL); break; } case IDM_TRAY_LOGCLEAR_ERR: { - if (!app.ShowConfirmMessage (hwnd, NULL, app.LocaleString (IDS_QUESTION, NULL), L"ConfirmLogClear")) + if (!app.ShowConfirmMessage (hwnd, NULL, app.LocaleString (IDS_QUESTION, NULL).GetString (), L"ConfirmLogClear")) break; LPCWSTR path = app.GetLogPath (); @@ -3917,7 +3917,7 @@ find_wrap: if (*p) { - app_hash = _app_addapplication (hwnd, _r_fmt (L"%s\\%s", dir, p), 0, 0, 0, FALSE, FALSE); + app_hash = _app_addapplication (hwnd, _r_fmt (L"%s\\%s", dir, p).GetString (), 0, 0, 0, FALSE, FALSE); } } } @@ -3970,8 +3970,7 @@ find_wrap: if (new_val == INVALID_INT) new_val = !ptr_app->is_silent; - if (ptr_app->is_silent != new_val) - ptr_app->is_silent = new_val; + ptr_app->is_silent = new_val; if (new_val) _app_freenotify (app_hash, ptr_app); @@ -4017,13 +4016,13 @@ find_wrap: buffer.Append (_r_listview_getitemtext (hwnd, listview_id, item, column_current)).Append (divider); } - _r_str_trim (buffer, divider); + _r_str_trim (buffer, divider.GetString ()); buffer.Append (L"\r\n"); } _r_str_trim (buffer, DIVIDER_TRIM); - _r_clipboard_set (hwnd, buffer, buffer.GetLength ()); + _r_clipboard_set (hwnd, buffer.GetString (), buffer.GetLength ()); break; } @@ -4191,7 +4190,7 @@ find_wrap: { rstring item_text = _r_listview_getitemtext (hwnd, listview_id, item, 0); - _r_str_alloc (&ptr_rule->pname, item_text.GetLength (), item_text); + _r_str_alloc (&ptr_rule->pname, item_text.GetLength (), item_text.GetString ()); } if (ptr_network->app_hash && !_r_str_isempty (ptr_network->path)) @@ -4233,7 +4232,7 @@ find_wrap: { rstring item_text = _r_listview_getitemtext (hwnd, listview_id, item, 0); - _r_str_alloc (&ptr_rule->pname, item_text.GetLength (), item_text); + _r_str_alloc (&ptr_rule->pname, item_text.GetLength (), item_text.GetString ()); } if (ptr_log->app_hash && !_r_str_isempty (ptr_log->path)) @@ -4456,7 +4455,7 @@ find_wrap: 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; @@ -4630,7 +4629,7 @@ find_wrap: case IDM_PURGE_TIMERS: { - if (!_app_istimersactive () || app.ShowMessage (hwnd, MB_YESNO | MB_ICONEXCLAMATION, NULL, NULL, app.LocaleString (IDS_QUESTION_TIMERS, NULL)) != IDYES) + if (!_app_istimersactive () || app.ShowMessage (hwnd, MB_YESNO | MB_ICONEXCLAMATION, NULL, NULL, app.LocaleString (IDS_QUESTION_TIMERS, NULL).GetString ()) != IDYES) break; OBJECTS_VEC rules; @@ -4780,10 +4779,10 @@ find_wrap: } if (layer) - FwpmFreeMemory ((LPVOID*)&layer); + FwpmFreeMemory ((PVOID*)&layer); if (filter) - FwpmFreeMemory ((LPVOID*)&filter); + FwpmFreeMemory ((PVOID*)&filter); } LPCWSTR terminator = NULL; diff --git a/src/main.hpp b/src/main.hpp index 16d89b18..86271017 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -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 diff --git a/src/notifications.cpp b/src/notifications.cpp index 20fb3457..0fe1c4b6 100644 --- a/src/notifications.cpp +++ b/src/notifications.cpp @@ -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) { diff --git a/src/profile.cpp b/src/profile.cpp index 1ff698f7..9ec80915 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -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); } diff --git a/src/security.cpp b/src/security.cpp index 55440798..83c171f8 100644 --- a/src/security.cpp +++ b/src/security.cpp @@ -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); } diff --git a/src/timer.cpp b/src/timer.cpp index 6e2989da..76c6ff8c 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -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 ()); } diff --git a/src/wfp.cpp b/src/wfp.cpp index 019b7ab2..2d79a8ee 100644 --- a/src/wfp.cpp +++ b/src/wfp.cpp @@ -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; }