diff --git a/src/controls.c b/src/controls.c index 609fde7f..6089d08c 100644 --- a/src/controls.c +++ b/src/controls.c @@ -864,7 +864,15 @@ VOID _app_toolbar_init ( SendMessage (config.htoolbar, WM_SETFONT, (WPARAM)config.wnd_font, TRUE); // fix font SendMessage (config.htoolbar, TB_SETIMAGELIST, 0, (LPARAM)config.himg_toolbar); - _r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_START, 0, BTNS_BUTTON | BTNS_AUTOSIZE, TBSTATE_ENABLED, I_IMAGENONE); + _r_toolbar_addbutton ( + config.hrebar, + IDC_TOOLBAR, + IDM_TRAY_START, + 0, + BTNS_BUTTON | BTNS_AUTOSIZE, + TBSTATE_ENABLED, + I_IMAGENONE + ); _r_toolbar_addseparator (config.hrebar, IDC_TOOLBAR); @@ -880,9 +888,34 @@ VOID _app_toolbar_init ( _r_toolbar_addseparator (config.hrebar, IDC_TOOLBAR); - _r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLENOTIFICATIONS_CHK, 0, BTNS_BUTTON | BTNS_AUTOSIZE, TBSTATE_ENABLED, 4); - _r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLELOG_CHK, 0, BTNS_BUTTON | BTNS_AUTOSIZE, TBSTATE_ENABLED, 5); - _r_toolbar_addbutton (config.hrebar, IDC_TOOLBAR, IDM_TRAY_ENABLEUILOG_CHK, 0, BTNS_BUTTON | BTNS_AUTOSIZE, TBSTATE_ENABLED, 10); + _r_toolbar_addbutton ( + config.hrebar, + IDC_TOOLBAR, + IDM_TRAY_ENABLENOTIFICATIONS_CHK, + 0, + BTNS_BUTTON | BTNS_AUTOSIZE, + TBSTATE_ENABLED, + 4 + ); + _r_toolbar_addbutton ( + config.hrebar, + IDC_TOOLBAR, + IDM_TRAY_ENABLELOG_CHK, + 0, + BTNS_BUTTON | BTNS_AUTOSIZE, + TBSTATE_ENABLED, + 5 + ); + + _r_toolbar_addbutton ( + config.hrebar, + IDC_TOOLBAR, + IDM_TRAY_ENABLEUILOG_CHK, + 0, + BTNS_BUTTON | BTNS_AUTOSIZE, + TBSTATE_ENABLED, + 10 + ); _r_toolbar_addseparator (config.hrebar, IDC_TOOLBAR); diff --git a/src/db.c b/src/db.c index c27e4021..067df7fe 100644 --- a/src/db.c +++ b/src/db.c @@ -625,9 +625,12 @@ NTSTATUS _app_db_parser_decodebody ( GetSystemInfo (&si); - if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM || si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64 || - si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) + if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM || + si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64 || + si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) + { return STATUS_SUCCESS; + } // validate hash return _app_db_ishashvalid (&db_info->bytes->sr, &db_info->hash->sr); @@ -716,6 +719,7 @@ NTSTATUS _app_db_parser_generatebody ( ) { PR_BYTE bytes; + PVOID ptr; if (profile_type == PROFILE2_ID_PLAIN) { @@ -725,29 +729,16 @@ NTSTATUS _app_db_parser_generatebody ( { bytes = _r_obj_createbyte_ex (NULL, PROFILE2_HEADER_LENGTH + body_value->length); - RtlCopyMemory ( - bytes->buffer, - profile2_fourcc, - sizeof (profile2_fourcc) - ); + RtlCopyMemory (bytes->buffer,profile2_fourcc,sizeof (profile2_fourcc)); - RtlCopyMemory ( - PTR_ADD_OFFSET (bytes->buffer, sizeof (profile2_fourcc)), - &profile_type, - sizeof (BYTE) - ); + ptr = PTR_ADD_OFFSET (bytes->buffer, sizeof (profile2_fourcc)); + RtlCopyMemory (ptr, &profile_type, sizeof (BYTE)); - RtlCopyMemory ( - PTR_ADD_OFFSET (bytes->buffer, PROFILE2_FOURCC_LENGTH), - hash_value->buffer, - hash_value->length - ); + ptr = PTR_ADD_OFFSET (bytes->buffer, PROFILE2_FOURCC_LENGTH); + RtlCopyMemory (ptr, hash_value->buffer, hash_value->length); - RtlCopyMemory ( - PTR_ADD_OFFSET (bytes->buffer, PROFILE2_HEADER_LENGTH), - body_value->buffer, - body_value->length - ); + ptr = PTR_ADD_OFFSET (bytes->buffer, PROFILE2_HEADER_LENGTH); + RtlCopyMemory (ptr, body_value->buffer, body_value->length); } else { @@ -786,11 +777,7 @@ NTSTATUS _app_db_parser_validatefile ( if (status != STATUS_SUCCESS) return status; - status = _r_xml_parsestring ( - &db_info->xml_library, - db_info->bytes->buffer, - (ULONG)db_info->bytes->length - ); + status = _r_xml_parsestring (&db_info->xml_library,db_info->bytes->buffer,(ULONG)db_info->bytes->length); if (FAILED (status)) return status; @@ -1256,6 +1243,7 @@ PR_STRING _app_db_getdirectionname ( return _r_obj_createstring (text); } +_Ret_maybenull_ PR_STRING _app_db_getprotoname ( _In_ ULONG proto, _In_ ADDRESS_FAMILY af, diff --git a/src/db.h b/src/db.h index 31cae3cf..16c3ec63 100644 --- a/src/db.h +++ b/src/db.h @@ -216,6 +216,7 @@ PR_STRING _app_db_getdirectionname ( _In_ BOOLEAN is_localized ); +_Ret_maybenull_ PR_STRING _app_db_getprotoname ( _In_ ULONG proto, _In_ ADDRESS_FAMILY af, diff --git a/src/editor.c b/src/editor.c index a8f41cbf..5b675c45 100644 --- a/src/editor.c +++ b/src/editor.c @@ -19,12 +19,7 @@ PEDITOR_CONTEXT _app_editor_createwindow ( context->page_id = page_id; context->is_settorules = is_settorules; - if (_r_wnd_createmodalwindow ( - _r_sys_getimagebase (), - MAKEINTRESOURCE (IDD_EDITOR), - hwnd, - &EditorProc, - context)) + if (_r_wnd_createmodalwindow (_r_sys_getimagebase (), MAKEINTRESOURCE (IDD_EDITOR), hwnd, &EditorProc, context)) { return context; } @@ -71,25 +66,12 @@ VOID _app_editor_addtabitem ( { HWND htab; - htab = _r_wnd_createwindow ( - _r_sys_getimagebase (), - MAKEINTRESOURCE (dlg_id), - hwnd, - &EditorPagesProc, - context - ); + htab = _r_wnd_createwindow (_r_sys_getimagebase (), MAKEINTRESOURCE (dlg_id), hwnd, &EditorPagesProc, context); if (!htab) return; - _r_tab_additem ( - hwnd, - IDC_TAB, - *tabs_count, - _r_locale_getstring (locale_id), - I_IMAGENONE, - (LPARAM)htab - ); + _r_tab_additem (hwnd, IDC_TAB, *tabs_count, _r_locale_getstring (locale_id), I_IMAGENONE, (LPARAM)htab); *tabs_count += 1; @@ -434,9 +416,7 @@ INT_PTR CALLBACK EditorRuleProc ( } if (context->item_id != -1) - { _r_listview_deleteitem (context->hwnd, context->listview_id, context->item_id); - } _r_listview_setcolumn (context->hwnd, context->listview_id, 0, NULL, -100); @@ -513,21 +493,7 @@ INT_PTR CALLBACK EditorPagesProc ( _r_ctrl_enable (GetParent (hwnd), IDC_SAVE, FALSE); } - SendDlgItemMessage ( - hwnd, - IDC_RULE_NAME_ID, - EM_LIMITTEXT, - RULE_NAME_CCH_MAX - 1, - 0 - ); - - SendDlgItemMessage ( - hwnd, - IDC_RULE_NAME_ID, - EM_SETREADONLY, - (WPARAM)context->ptr_rule->is_readonly, - 0 - ); + _r_ctrl_setreadonly (hwnd, IDC_RULE_NAME_ID, RULE_NAME_CCH_MAX - 1, !!context->ptr_rule->is_readonly); } // direction @@ -712,6 +678,7 @@ INT_PTR CALLBACK EditorPagesProc ( if (GetDlgItem (hwnd, IDC_RULE_LOCAL_ID)) { _r_ctrl_setstringformat (hwnd, IDC_RULE_LOCAL, L"%s (" SZ_DIRECTION_LOCAL L"):", _r_locale_getstring (IDS_RULE)); + _r_listview_setstyle ( hwnd, IDC_RULE_LOCAL_ID, @@ -744,15 +711,7 @@ INT_PTR CALLBACK EditorPagesProc ( { _app_search_initialize (hctrl); - SetWindowPos ( - hctrl, - HWND_BOTTOM, - 0, - 0, - 0, - 0, - SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED - ); // HACK!!! + SetWindowPos (hctrl, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED); // HACK!!! } // apps @@ -898,6 +857,7 @@ INT_PTR CALLBACK EditorPagesProc ( ); _r_listview_addcolumn (hwnd, IDC_APP_RULES_ID, 0, _r_locale_getstring (IDS_NAME), 0, LVCFMT_LEFT); + _r_listview_addgroup (hwnd, IDC_APP_RULES_ID, 0, _r_locale_getstring (IDS_TRAY_SYSTEM_RULES), 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE); _r_listview_addgroup (hwnd, IDC_APP_RULES_ID, 1, _r_locale_getstring (IDS_TRAY_USER_RULES), 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE); _r_listview_addgroup (hwnd, IDC_APP_RULES_ID, LV_HIDDEN_GROUP_ID, L"", 2, LVGS_COLLAPSED, LVGS_COLLAPSED); @@ -1121,7 +1081,6 @@ INT_PTR CALLBACK EditorPagesProc ( ); _r_menu_additem (hsubmenu, id_edit, localized_string->buffer); - _r_menu_additem (hsubmenu, id_delete, _r_locale_getstring (IDS_DELETE)); _r_menu_additem (hsubmenu, 0, NULL); _r_menu_additem (hsubmenu, IDM_COPY, _r_locale_getstring (IDS_COPY)); @@ -1222,6 +1181,7 @@ INT_PTR CALLBACK EditorPagesProc ( { LPNMLISTVIEW lpnmlv; INT listview_id; + BOOLEAN is_locked; lpnmlv = (LPNMLISTVIEW)lparam; listview_id = (INT)(INT_PTR)lpnmlv->hdr.idFrom; @@ -1238,7 +1198,9 @@ INT_PTR CALLBACK EditorPagesProc ( if ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (1) || ((lpnmlv->uNewState & LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK (2))) { - if (!_app_listview_islocked (hwnd, (INT)(INT_PTR)lpnmlv->hdr.idFrom) && context->ptr_rule->type != DATA_RULE_USER) + is_locked = _app_listview_islocked (hwnd, (INT)(INT_PTR)lpnmlv->hdr.idFrom); + + if (!is_locked && context->ptr_rule->type != DATA_RULE_USER) { SetWindowLongPtr (hwnd, DWLP_MSGRESULT, TRUE); return TRUE; @@ -1403,7 +1365,8 @@ INT_PTR CALLBACK EditorPagesProc ( if (!_r_ctrl_isenabled (hwnd, ctrl_id)) break; - listview_id = (ctrl_id == IDC_RULE_REMOTE_ADD || ctrl_id == IDC_RULE_REMOTE_EDIT) ? IDC_RULE_REMOTE_ID : IDC_RULE_LOCAL_ID; + listview_id = (ctrl_id == IDC_RULE_REMOTE_ADD || + ctrl_id == IDC_RULE_REMOTE_EDIT) ? IDC_RULE_REMOTE_ID : IDC_RULE_LOCAL_ID; if (ctrl_id == IDC_RULE_REMOTE_EDIT || ctrl_id == IDC_RULE_LOCAL_EDIT) { @@ -1452,7 +1415,13 @@ INT_PTR CALLBACK EditorPagesProc ( context->item_id = item_id; context->current_length = current_length; - _r_wnd_createmodalwindow (_r_sys_getimagebase (), MAKEINTRESOURCE (IDD_EDITOR_ADDRULE), hwnd, &EditorRuleProc, context); + _r_wnd_createmodalwindow ( + _r_sys_getimagebase (), + MAKEINTRESOURCE (IDD_EDITOR_ADDRULE), + hwnd, + &EditorRuleProc, + context + ); break; } @@ -1471,7 +1440,11 @@ INT_PTR CALLBACK EditorPagesProc ( if (!selected_count) break; - if (_r_show_message (hwnd, MB_YESNO | MB_ICONEXCLAMATION, NULL, _r_locale_getstring (IDS_QUESTION_DELETE)) != IDYES) + if (_r_show_message ( + hwnd, + MB_YESNO | MB_ICONEXCLAMATION, + NULL, + _r_locale_getstring (IDS_QUESTION_DELETE)) != IDYES) { break; } @@ -1814,13 +1787,13 @@ INT_PTR CALLBACK EditorProc ( item_id = _r_tab_getcurrentitem (hwnd, IDC_TAB); hpage = (HWND)_r_tab_getitemlparam (hwnd, IDC_TAB, item_id); - if (hpage) - { - _r_tab_adjustchild (hwnd, IDC_TAB, hpage); + if (!hpage) + break; - ShowWindow (hpage, SW_SHOWNA); - SetFocus (NULL); - } + _r_tab_adjustchild (hwnd, IDC_TAB, hpage); + + ShowWindow (hpage, SW_SHOWNA); + SetFocus (NULL); break; } @@ -2022,13 +1995,7 @@ INT_PTR CALLBACK EditorProc ( { is_enable = _r_listview_isitemchecked (hpage_rule, IDC_APP_RULES_ID, i); - _app_setruletoapp ( - _r_app_gethwnd (), - ptr_rule, - item_id, - context->ptr_app, - is_enable - ); + _app_setruletoapp (_r_app_gethwnd (), ptr_rule, item_id, context->ptr_app, is_enable); } } diff --git a/src/helper.c b/src/helper.c index 59cbf0d9..ad193c40 100644 --- a/src/helper.c +++ b/src/helper.c @@ -327,22 +327,14 @@ PR_STRING _app_formataddress_interlocked ( PR_STRING current_string; PR_STRING new_string; - current_string = InterlockedCompareExchangePointer ( - string, - NULL, - NULL - ); + current_string = InterlockedCompareExchangePointer (string, NULL, NULL); if (current_string) return current_string; new_string = _app_formataddress (af, 0, address, 0, 0); - current_string = InterlockedCompareExchangePointer ( - string, - new_string, - NULL - ); + current_string = InterlockedCompareExchangePointer (string, new_string, NULL); if (!current_string) { @@ -380,12 +372,7 @@ BOOLEAN _app_formatip ( return FALSE; } - status = RtlIpv4AddressToStringEx ( - p4addr, - 0, - buffer, - &buffer_size - ); + status = RtlIpv4AddressToStringEx (p4addr, 0, buffer, &buffer_size); if (status == STATUS_SUCCESS) return TRUE; @@ -400,13 +387,7 @@ BOOLEAN _app_formatip ( return FALSE; } - status = RtlIpv6AddressToStringEx ( - p6addr, - 0, - 0, - buffer, - &buffer_size - ); + status = RtlIpv6AddressToStringEx (p6addr, 0, 0, buffer, &buffer_size); if (status == STATUS_SUCCESS) return TRUE; @@ -475,11 +456,7 @@ BOOLEAN _app_getappinfoparam2 ( if (ptr_app_info) { - icon_id = InterlockedCompareExchange ( - &ptr_app_info->large_icon_id, - 0, - 0 - ); + icon_id = InterlockedCompareExchange (&ptr_app_info->large_icon_id, 0, 0); } else { @@ -567,6 +544,8 @@ BOOLEAN _app_isappsigned ( PR_STRING string; BOOLEAN is_signed; + string = NULL; + if (_app_getappinfoparam2 (app_hash, INFO_SIGNATURE_STRING, &string, sizeof (string))) { is_signed = !_r_obj_isstringempty2 (string); @@ -693,23 +672,11 @@ VOID _app_getfileicon ( if (is_iconshidded || !_app_isappvalidbinary (ptr_app_info->type, ptr_app_info->path)) { - _app_icons_loadfromfile ( - NULL, - ptr_app_info->type, - &icon_id, - NULL, - TRUE - ); + _app_icons_loadfromfile (NULL, ptr_app_info->type, &icon_id, NULL, TRUE); } else { - _app_icons_loadfromfile ( - ptr_app_info->path, - ptr_app_info->type, - &icon_id, - NULL, - TRUE - ); + _app_icons_loadfromfile (ptr_app_info->path, ptr_app_info->type, &icon_id, NULL, TRUE); } InterlockedCompareExchange ( @@ -730,7 +697,6 @@ BOOLEAN _app_calculatefilehash ( { static R_INITONCE init_once = PR_INITONCE_INIT; static GUID DriverActionVerify = DRIVER_ACTION_VERIFY; - static CCAAC2 _CryptCATAdminAcquireContext2 = NULL; static CCAHFFH2 _CryptCATAdminCalcHashFromFileHandle2 = NULL; @@ -745,15 +711,8 @@ BOOLEAN _app_calculatefilehash ( if (hwintrust) { - _CryptCATAdminAcquireContext2 = (CCAAC2)GetProcAddress ( - hwintrust, - "CryptCATAdminAcquireContext2" - ); - - _CryptCATAdminCalcHashFromFileHandle2 = (CCAHFFH2)GetProcAddress ( - hwintrust, - "CryptCATAdminCalcHashFromFileHandle2" - ); + _CryptCATAdminAcquireContext2 = (CCAAC2)GetProcAddress (hwintrust, "CryptCATAdminAcquireContext2"); + _CryptCATAdminCalcHashFromFileHandle2 = (CCAHFFH2)GetProcAddress (hwintrust, "CryptCATAdminCalcHashFromFileHandle2"); //FreeLibrary (hwintrust); } @@ -763,15 +722,8 @@ BOOLEAN _app_calculatefilehash ( if (_CryptCATAdminAcquireContext2) { - if (!_CryptCATAdminAcquireContext2 ( - &hcat_admin, - &DriverActionVerify, - algorithm_id, - NULL, - 0)) - { + if (!_CryptCATAdminAcquireContext2 (&hcat_admin, &DriverActionVerify, algorithm_id, NULL, 0)) return FALSE; - } } else { @@ -784,21 +736,11 @@ BOOLEAN _app_calculatefilehash ( if (_CryptCATAdminCalcHashFromFileHandle2) { - if (!_CryptCATAdminCalcHashFromFileHandle2 ( - hcat_admin, - hfile, - &file_hash_length, - file_hash, - 0)) + if (!_CryptCATAdminCalcHashFromFileHandle2 (hcat_admin, hfile, &file_hash_length, file_hash, 0)) { file_hash = _r_mem_reallocatezero (file_hash, file_hash_length); - if (!_CryptCATAdminCalcHashFromFileHandle2 ( - hcat_admin, - hfile, - &file_hash_length, - file_hash, - 0)) + if (!_CryptCATAdminCalcHashFromFileHandle2 (hcat_admin, hfile, &file_hash_length, file_hash, 0)) { CryptCATAdminReleaseContext (hcat_admin, 0); _r_mem_free (file_hash); @@ -809,19 +751,11 @@ BOOLEAN _app_calculatefilehash ( } else { - if (!CryptCATAdminCalcHashFromFileHandle ( - hfile, - &file_hash_length, - file_hash, - 0)) + if (!CryptCATAdminCalcHashFromFileHandle (hfile, &file_hash_length, file_hash, 0)) { file_hash = _r_mem_reallocatezero (file_hash, file_hash_length); - if (!CryptCATAdminCalcHashFromFileHandle ( - hfile, - &file_hash_length, - file_hash, - 0)) + if (!CryptCATAdminCalcHashFromFileHandle (hfile, &file_hash_length, file_hash, 0)) { CryptCATAdminReleaseContext (hcat_admin, 0); _r_mem_free (file_hash); @@ -846,10 +780,8 @@ PR_STRING _app_verifygetstring ( PCRYPT_PROVIDER_DATA prov_data; PCRYPT_PROVIDER_SGNR prov_signer; PCRYPT_PROVIDER_CERT prov_cert; - PR_STRING string; ULONG length; - ULONG idx; prov_data = WTHelperProvDataFromStateData (state_data); @@ -870,26 +802,13 @@ PR_STRING _app_verifygetstring ( if (!prov_cert) break; - length = CertGetNameString ( - prov_cert->pCert, - CERT_NAME_ATTR_TYPE, - 0, - szOID_COMMON_NAME, - NULL, - 0) - 1; + length = CertGetNameString (prov_cert->pCert, CERT_NAME_ATTR_TYPE, 0, szOID_COMMON_NAME, NULL, 0) - 1; if (length > 1) { string = _r_obj_createstring_ex (NULL, length * sizeof (WCHAR)); - CertGetNameString ( - prov_cert->pCert, - CERT_NAME_ATTR_TYPE, - 0, - szOID_COMMON_NAME, - string->buffer, - length + 1 - ); + CertGetNameString (prov_cert->pCert, CERT_NAME_ATTR_TYPE, 0, szOID_COMMON_NAME, string->buffer, length + 1); _r_obj_trimstringtonullterminator (string); @@ -991,20 +910,9 @@ LONG _app_verifyfilefromcatalog ( string = NULL; status = TRUST_E_FAIL; - if (_app_calculatefilehash ( - hfile, - algorithm_id, - &file_hash, - &file_hash_length, - &hcat_admin)) + if (_app_calculatefilehash (hfile, algorithm_id, &file_hash, &file_hash_length, &hcat_admin)) { - hcat_info = CryptCATAdminEnumCatalogFromHash ( - hcat_admin, - file_hash, - file_hash_length, - 0, - NULL - ); + hcat_info = CryptCATAdminEnumCatalogFromHash (hcat_admin, file_hash, file_hash_length, 0, NULL); if (hcat_info) { @@ -1024,13 +932,7 @@ LONG _app_verifyfilefromcatalog ( catalog_info.cbCalculatedFileHash = file_hash_length; catalog_info.hCatAdmin = hcat_admin; - status = _app_verifyfromfile ( - WTD_CHOICE_CATALOG, - &catalog_info, - &DriverActionVerify, - &ver_info, - &string - ); + status = _app_verifyfromfile (WTD_CHOICE_CATALOG, &catalog_info, &DriverActionVerify, &ver_info, &string); if (ver_info.pcSignerCertContext) CertFreeCertificateContext (ver_info.pcSignerCertContext); @@ -1058,7 +960,6 @@ VOID _app_getfilesignatureinfo ( static GUID WinTrustActionGenericVerifyV2 = WINTRUST_ACTION_GENERIC_VERIFY_V2; WINTRUST_FILE_INFO file_info = {0}; - HANDLE hfile; PR_STRING string; LONG status; @@ -1086,33 +987,17 @@ VOID _app_getfilesignatureinfo ( file_info.pcwszFilePath = ptr_app_info->path->buffer; file_info.hFile = hfile; - status = _app_verifyfromfile ( - WTD_CHOICE_FILE, - &file_info, - &WinTrustActionGenericVerifyV2, - NULL, - &string - ); + status = _app_verifyfromfile (WTD_CHOICE_FILE, &file_info, &WinTrustActionGenericVerifyV2, NULL, &string); if (status == TRUST_E_NOSIGNATURE) { if (_r_sys_isosversiongreaterorequal (WINDOWS_8)) { - status = _app_verifyfilefromcatalog ( - hfile, - ptr_app_info->path->buffer, - BCRYPT_SHA256_ALGORITHM, - &string - ); + status = _app_verifyfilefromcatalog (hfile, ptr_app_info->path->buffer, BCRYPT_SHA256_ALGORITHM, &string); } else { - status = _app_verifyfilefromcatalog ( - hfile, - ptr_app_info->path->buffer, - NULL, - &string - ); + status = _app_verifyfilefromcatalog (hfile, ptr_app_info->path->buffer, NULL, &string); } } @@ -1139,11 +1024,7 @@ VOID _app_getfileversioninfo ( if (!_app_isappvalidbinary (ptr_app_info->type, ptr_app_info->path)) goto CleanupExit; - hlib = LoadLibraryEx ( - ptr_app_info->path->buffer, - NULL, - LOAD_LIBRARY_AS_IMAGE_RESOURCE | LOAD_LIBRARY_AS_DATAFILE - ); + hlib = LoadLibraryEx (ptr_app_info->path->buffer, NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE | LOAD_LIBRARY_AS_DATAFILE); if (!hlib) goto CleanupExit; @@ -1458,11 +1339,7 @@ BOOLEAN _app_setruletoapp ( { listview_id = _app_listview_getbytype (ptr_rule->type); - _app_listview_updateitemby_param ( - hwnd, - _app_listview_getitemcontext (hwnd, listview_id, item_id), - FALSE - ); + _app_listview_updateitemby_param (hwnd, _app_listview_getitemcontext (hwnd, listview_id, item_id), FALSE); } _app_listview_updateitemby_param (hwnd, ptr_app->app_hash, TRUE); @@ -1480,7 +1357,7 @@ BOOLEAN _app_parsenetworkstring ( NET_ADDRESS_INFO ni_end; ULONG mask; ULONG types; - ULONG code; + ULONG status; USHORT range_port1; USHORT range_port2; USHORT port; @@ -1494,12 +1371,12 @@ BOOLEAN _app_parsenetworkstring ( range_port1 = 0; range_port2 = 0; - code = ParseNetworkString (address->range_start, types, &ni, &range_port1, NULL); + status = ParseNetworkString (address->range_start, types, &ni, &range_port1, NULL); - if (code != ERROR_SUCCESS) + if (status != ERROR_SUCCESS) goto CleanupExit; - code = ParseNetworkString (address->range_end, types, &ni_end, &range_port2, NULL); + status = ParseNetworkString (address->range_end, types, &ni_end, &range_port2, NULL); if (range_port2) { @@ -1516,10 +1393,10 @@ BOOLEAN _app_parsenetworkstring ( } else { - code = ParseNetworkString (network_string, types, &ni, &port, &prefix_length); + status = ParseNetworkString (network_string, types, &ni, &port, &prefix_length); } - if (code != ERROR_SUCCESS) + if (status != ERROR_SUCCESS) goto CleanupExit; address->format = ni.Format; @@ -1571,7 +1448,7 @@ BOOLEAN _app_parsenetworkstring ( CleanupExit: - _r_log (LOG_LEVEL_INFO, NULL, L"ParseNetworkString", code, network_string); + _r_log (LOG_LEVEL_INFO, NULL, L"ParseNetworkString", status, network_string); return FALSE; } @@ -1622,12 +1499,7 @@ BOOLEAN _app_preparserulestring ( } // parse rule range - address->is_range = _r_str_splitatchar ( - rule, - DIVIDER_RULE_RANGE, - &range_start_part, - &range_end_part - ); + address->is_range = _r_str_splitatchar (rule, DIVIDER_RULE_RANGE, &range_start_part, &range_end_part); // extract start and end position of rule if (address->is_range) @@ -1778,11 +1650,7 @@ PR_STRING _app_resolveaddress ( arpa_string = _app_formatarpa (af, address); arpa_hash = _r_str_gethash2 (arpa_string, TRUE); - if (_app_getcachetable ( - cache_resolution, - arpa_hash, - &lock_cache_resolution, - &string)) + if (_app_getcachetable (cache_resolution, arpa_hash, &lock_cache_resolution, &string)) { _r_obj_dereference (arpa_string); return string; @@ -1791,14 +1659,7 @@ PR_STRING _app_resolveaddress ( dns_records = NULL; string = NULL; - status = DnsQuery ( - arpa_string->buffer, - DNS_TYPE_PTR, - DNS_QUERY_NO_HOSTS_FILE, - NULL, - &dns_records, - NULL - ); + status = DnsQuery (arpa_string->buffer, DNS_TYPE_PTR, DNS_QUERY_NO_HOSTS_FILE, NULL, &dns_records, NULL); if (status == NO_ERROR) { @@ -1820,12 +1681,7 @@ PR_STRING _app_resolveaddress ( if (!string) string = _r_obj_referenceemptystring (); - _app_addcachetable ( - cache_resolution, - arpa_hash, - &lock_cache_resolution, - _r_obj_reference (string) - ); + _app_addcachetable (cache_resolution, arpa_hash, &lock_cache_resolution, _r_obj_reference (string)); _r_obj_dereference (arpa_string); @@ -1842,11 +1698,7 @@ PR_STRING _app_resolveaddress_interlocked ( PR_STRING current_string; PR_STRING new_string; - current_string = InterlockedCompareExchangePointer ( - string, - NULL, - NULL - ); + current_string = InterlockedCompareExchangePointer (string, NULL, NULL); if (current_string) return current_string; @@ -1863,11 +1715,7 @@ PR_STRING _app_resolveaddress_interlocked ( new_string = _r_obj_referenceemptystring (); } - current_string = InterlockedCompareExchangePointer ( - string, - new_string, - NULL - ); + current_string = InterlockedCompareExchangePointer (string, new_string, NULL); if (!current_string) { @@ -1919,7 +1767,9 @@ VOID _app_queue_fileinformation ( ptr_app_info->listview_id = listview_id; _r_queuedlock_acquireexclusive (&lock_cache_information); + _r_obj_addhashtablepointer (cache_information, app_hash, _r_obj_reference (ptr_app_info)); + _r_queuedlock_releaseexclusive (&lock_cache_information); } @@ -2013,23 +1863,12 @@ VOID NTAPI _app_queuenotifyinformation ( ptr_log = context->base_address; // query address string - address_str = _app_formataddress ( - ptr_log->af, - ptr_log->protocol, - &ptr_log->remote_addr, - 0, - FMTADDR_USE_PROTOCOL - ); + address_str = _app_formataddress (ptr_log->af, ptr_log->protocol, &ptr_log->remote_addr, 0, FMTADDR_USE_PROTOCOL); // query notification host name if (_r_config_getboolean (L"IsNetworkResolutionsEnabled", FALSE)) { - host_str = _app_resolveaddress_interlocked ( - &ptr_log->remote_host_str, - ptr_log->af, - &ptr_log->remote_addr, - TRUE - ); + host_str = _app_resolveaddress_interlocked (&ptr_log->remote_host_str, ptr_log->af, &ptr_log->remote_addr, TRUE); //if (host_str) // host_str = _r_obj_reference (host_str); @@ -2167,35 +2006,16 @@ VOID NTAPI _app_queueresolveinformation ( { ptr_log = context->base_address; - _app_resolveaddress_interlocked ( - &ptr_log->local_host_str, - ptr_log->af, - &ptr_log->local_addr, - is_resolutionenabled - ); + _app_resolveaddress_interlocked (&ptr_log->local_host_str, ptr_log->af, &ptr_log->local_addr, is_resolutionenabled); - _app_resolveaddress_interlocked ( - &ptr_log->remote_host_str, - ptr_log->af, - &ptr_log->remote_addr, - is_resolutionenabled - ); + _app_resolveaddress_interlocked (&ptr_log->remote_host_str, ptr_log->af, &ptr_log->remote_addr, is_resolutionenabled); } else if (context->listview_id == IDC_NETWORK) { ptr_network = context->base_address; - _app_formataddress_interlocked ( - &ptr_network->local_addr_str, - ptr_network->af, - &ptr_network->local_addr - ); - - _app_formataddress_interlocked ( - &ptr_network->remote_addr_str, - ptr_network->af, - &ptr_network->remote_addr - ); + _app_formataddress_interlocked (&ptr_network->local_addr_str, ptr_network->af, &ptr_network->local_addr); + _app_formataddress_interlocked (&ptr_network->remote_addr_str, ptr_network->af, &ptr_network->remote_addr); _app_resolveaddress_interlocked ( &ptr_network->local_host_str, @@ -2205,8 +2025,7 @@ VOID NTAPI _app_queueresolveinformation ( ); _app_resolveaddress_interlocked ( - &ptr_network->remote_host_str, - ptr_network->af, + &ptr_network->remote_host_str, ptr_network->af, &ptr_network->remote_addr, is_resolutionenabled ); @@ -2239,13 +2058,7 @@ HBITMAP _app_bitmapfrompng ( if (!_r_res_loadresource (hinst, name, L"PNG", &buffer)) return NULL; - return _r_dc_imagetobitmap ( - &GUID_ContainerFormatPng, - buffer.buffer, - (ULONG)buffer.length, - width, - width - ); + return _r_dc_imagetobitmap (&GUID_ContainerFormatPng, buffer.buffer, (ULONG)buffer.length, width, width); } VOID _app_wufixhelper ( @@ -2271,13 +2084,7 @@ VOID _app_wufixhelper ( service_name ); - status = RegOpenKeyEx ( - HKEY_LOCAL_MACHINE, - reg_key, - 0, - KEY_READ | KEY_WRITE, - &hkey - ); + status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, reg_key, 0, KEY_READ | KEY_WRITE, &hkey); if (status != ERROR_SUCCESS) return; @@ -2321,11 +2128,7 @@ VOID _app_wufixhelper ( // restart service if (is_enable != is_enabled) { - hsvc = OpenService ( - hsvcmgr, - service_name, - SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS - ); + hsvc = OpenService (hsvcmgr, service_name, SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS); if (hsvc) { @@ -2367,11 +2170,7 @@ VOID _app_wufixenable ( _r_sys_getsystemdirectory ()->buffer ); - hsvcmgr = OpenSCManager ( - NULL, - NULL, - SC_MANAGER_CONNECT | SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS - ); + hsvcmgr = OpenSCManager (NULL, NULL, SC_MANAGER_CONNECT | SERVICE_START | SERVICE_STOP | SERVICE_QUERY_STATUS); if (!hsvcmgr) return; diff --git a/src/icons.c b/src/icons.c index 39efde25..d259de62 100644 --- a/src/icons.c +++ b/src/icons.c @@ -19,13 +19,7 @@ PICON_INFORMATION _app_icons_getdefault () L"\\svchost.exe" ); - _app_icons_loadfromfile ( - path, - 0, - &icon_info.app_icon_id, - &icon_info.app_hicon, - FALSE - ); + _app_icons_loadfromfile (path, 0, &icon_info.app_icon_id, &icon_info.app_hicon, FALSE); // load default service icons _r_obj_dereference (path); @@ -36,13 +30,7 @@ PICON_INFORMATION _app_icons_getdefault () L"\\shell32.dll" ); - _app_icons_loadfromfile ( - path, - 0, - &icon_info.service_icon_id, - &icon_info.service_hicon, - FALSE - ); + _app_icons_loadfromfile (path, 0, &icon_info.service_icon_id, &icon_info.service_hicon, FALSE); // load uwp icons if (_r_sys_isosversiongreaterorequal (WINDOWS_8)) @@ -55,13 +43,7 @@ PICON_INFORMATION _app_icons_getdefault () L"\\wsreset.exe" ); - _app_icons_loadfromfile ( - path, - 0, - &icon_info.uwp_icon_id, - &icon_info.uwp_hicon, - FALSE - ); + _app_icons_loadfromfile (path, 0, &icon_info.uwp_icon_id, &icon_info.uwp_hicon, FALSE); } _r_obj_dereference (path); @@ -160,13 +142,7 @@ HICON _app_icons_getsafeapp_hicon ( return hicon; } - _app_icons_loadfromfile ( - ptr_app->real_path, - ptr_app->type, - &icon_id, - &hicon, - TRUE - ); + _app_icons_loadfromfile (ptr_app->real_path, ptr_app->type, &icon_id, &hicon, TRUE); if (!icon_id || ((ptr_app->type == DATA_APP_UWP || ptr_app->type == DATA_APP_SERVICE) && icon_id == icon_info->app_icon_id)) diff --git a/src/listview.c b/src/listview.c index ce7dcd30..7eff9afb 100644 --- a/src/listview.c +++ b/src/listview.c @@ -223,7 +223,7 @@ VOID _app_listview_addnetworkitem ( VOID _app_listview_addlogitem ( _In_ HWND hwnd, - _In_ PITEM_LOG ptr_log, + _In_opt_ PITEM_LOG ptr_log, _In_ ULONG_PTR log_hash ) { @@ -245,6 +245,8 @@ VOID _app_listview_addlogitem ( 0, listview_context ); + + _r_listview_ensurevisible (hwnd, IDC_LOG, item_id); } BOOLEAN _app_listview_islocked ( @@ -646,23 +648,18 @@ VOID _app_listview_refreshgroups ( ) { WCHAR buffer[128]; - UINT group1_title; UINT group2_title; UINT group3_title; UINT group4_title; UINT group5_title; - INT total_count; - INT group1_count; INT group2_count; INT group3_count; INT group4_count; INT group5_count; - INT group_id; - BOOLEAN is_rules; if (!_r_listview_isgroupviewenabled (hwnd, listview_id)) @@ -918,22 +915,22 @@ VOID _app_listview_resize_ex ( { item_text = _r_listview_getitemtext (hwnd, listview_id, j, i); - if (item_text) + if (!item_text) + continue; + + text_width = _r_dc_getfontwidth (hdc_listview, &item_text->sr) + spacing; + + _r_obj_dereference (item_text); + + // do not continue reaching higher and higher values for performance reason! + if (text_width >= max_width) { - text_width = _r_dc_getfontwidth (hdc_listview, &item_text->sr) + spacing; - - _r_obj_dereference (item_text); - - // do not continue reaching higher and higher values for performance reason! - if (text_width >= max_width) - { - column_width = max_width; - break; - } - - if (text_width > column_width) - column_width = text_width; + column_width = max_width; + break; } + + if (text_width > column_width) + column_width = text_width; } } } @@ -1041,13 +1038,13 @@ INT CALLBACK _app_listview_compare_callback ( { WCHAR config_name[128]; HWND hwnd; + ULONG_PTR context1; + ULONG_PTR context2; LONG column_id; INT listview_id; INT result; INT item_id1; INT item_id2; - BOOLEAN is_descend; - PR_STRING item_text_1; PR_STRING item_text_2; PITEM_LOG ptr_log1; @@ -1058,6 +1055,7 @@ INT CALLBACK _app_listview_compare_callback ( BOOLEAN is_success2; BOOLEAN is_checked1; BOOLEAN is_checked2; + BOOLEAN is_descend; hwnd = GetParent ((HWND)lparam); @@ -1102,24 +1100,16 @@ INT CALLBACK _app_listview_compare_callback ( } } + context1 = _app_listview_getitemcontext (hwnd, listview_id, item_id1); + context2 = _app_listview_getitemcontext (hwnd, listview_id, item_id2); + if (!result) { // timestamp sorting if ((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP) && column_id == 1) { - is_success1 = _app_getappinfobyhash ( - _app_listview_getitemcontext (hwnd, listview_id, item_id1), - INFO_TIMESTAMP, - ×tamp1, - sizeof (timestamp1) - ); - - is_success2 = _app_getappinfobyhash ( - _app_listview_getitemcontext (hwnd, listview_id, item_id2), - INFO_TIMESTAMP, - ×tamp2, - sizeof (timestamp2) - ); + is_success1 = _app_getappinfobyhash (context1, INFO_TIMESTAMP, ×tamp1, sizeof (timestamp1)); + is_success2 = _app_getappinfobyhash (context2, INFO_TIMESTAMP, ×tamp2, sizeof (timestamp2)); if (is_success1 && is_success2) { @@ -1135,8 +1125,8 @@ INT CALLBACK _app_listview_compare_callback ( } else if (listview_id == IDC_LOG && column_id == 11) { - ptr_log1 = _app_getlogitem (_app_listview_getitemcontext (hwnd, listview_id, item_id1)); - ptr_log2 = _app_getlogitem (_app_listview_getitemcontext (hwnd, listview_id, item_id2)); + ptr_log1 = _app_getlogitem (context1); + ptr_log2 = _app_getlogitem (context2); if (ptr_log1 && ptr_log2) { @@ -1231,12 +1221,7 @@ VOID _app_listview_sort_ex ( _r_listview_setcolumnsortindex (hwnd, listview_id, column_id, is_descend ? -1 : 1); - SendMessage ( - hlistview, - LVM_SORTITEMSEX, - (WPARAM)hlistview, - (LPARAM)&_app_listview_compare_callback - ); + SendMessage (hlistview, LVM_SORTITEMSEX, (WPARAM)hlistview, (LPARAM)&_app_listview_compare_callback); } VOID _app_listview_sort ( diff --git a/src/listview.h b/src/listview.h index 8bcc3b40..c0b015ad 100644 --- a/src/listview.h +++ b/src/listview.h @@ -67,7 +67,7 @@ VOID _app_listview_addnetworkitem ( VOID _app_listview_addlogitem ( _In_ HWND hwnd, - _In_ PITEM_LOG ptr_log, + _In_opt_ PITEM_LOG ptr_log, _In_ ULONG_PTR log_hash ); diff --git a/src/log.c b/src/log.c index 21c6f021..9b5a0547 100644 --- a/src/log.c +++ b/src/log.c @@ -25,7 +25,15 @@ VOID _app_loginit ( if (!log_path) return; - new_handle = CreateFile (log_path->buffer, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + new_handle = CreateFile ( + log_path->buffer, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ, + NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL + ); if (_r_fs_isvalidhandle (new_handle)) { @@ -45,6 +53,7 @@ VOID _app_loginitfile ( ) { static BYTE bom[] = {0xFF, 0xFE}; + LONG64 file_size; ULONG unused; @@ -669,15 +678,11 @@ VOID CALLBACK _wfp_logcallback ( // remote address if (log->flags & FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET && log->remote_addr6) - { RtlCopyMemory (ptr_log->remote_addr6.u.Byte, log->remote_addr6->byteArray16, FWP_V6_ADDR_SIZE); - } // local address if (log->flags & FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET && log->local_addr6) - { RtlCopyMemory (ptr_log->local_addr6.u.Byte, log->local_addr6->byteArray16, FWP_V6_ADDR_SIZE); - } } } diff --git a/src/main.c b/src/main.c index 6a19d113..24669ec3 100644 --- a/src/main.c +++ b/src/main.c @@ -4133,9 +4133,11 @@ BOOLEAN _app_parseargs ( NULL, MB_OK | MB_ICONINFORMATION, L"Available options:", - L"\"simplewall.exe -install\" - enable filtering.\r\n\"simplewall.exe -install -temp\" - enable filtering until reboot.\r\n\" \ - simplewall.exe -install -silent\" - enable filtering without prompt.\r\n\"" \ - "simplewall.exe -uninstall\" - remove all installed filters.\r\n\"simplewall.exe -help\" - show this message." + L"\"simplewall.exe -install\" - enable filtering.\r\n" \ + "\"simplewall.exe -install -temp\" - enable filtering until reboot.\r\n\" \ + \"simplewall.exe -install -silent\" - enable filtering without prompt.\r\n\"" \ + "\"simplewall.exe -uninstall\" - remove all installed filters.\r\n" + "\"simplewall.exe -help\" - show this message." ); result = TRUE; @@ -4154,14 +4156,10 @@ BOOLEAN _app_parseargs ( if (is_install) { if (_r_sys_getopt (cmdline, L"silent", NULL)) - { is_silent = TRUE; - } if (_r_sys_getopt (cmdline, L"temp", NULL)) - { is_temporary = TRUE; - } } if (is_install || is_uninstall) diff --git a/src/messages.c b/src/messages.c index 5b3bbc14..1b848cf4 100644 --- a/src/messages.c +++ b/src/messages.c @@ -8,7 +8,6 @@ VOID _app_message_initialize ( ) { ENUM_INSTALL_TYPE install_type; - HMENU hmenu; LONG icon_size; LONG view_type; @@ -828,22 +827,20 @@ VOID _app_message_contextmenu ( HMENU hmenu; HMENU hsubmenu_rules; HMENU hsubmenu_timers; - PITEM_APP ptr_app; PITEM_NETWORK ptr_network; - PR_STRING localized_string; PR_STRING column_text; - ULONG_PTR hash_code; - INT listview_id; INT lv_column_current; INT command_id; - BOOLEAN is_checked; BOOLEAN is_readonly; + is_checked = FALSE; + is_readonly = FALSE; + if (lpnmlv->iItem == -1) return; @@ -1246,7 +1243,6 @@ VOID _app_message_traycontextmenu ( ) { ENUM_INSTALL_TYPE install_type; - HMENU hmenu; HMENU hsubmenu; @@ -1631,12 +1627,7 @@ LONG_PTR _app_message_custdraw ( // draw text if ((tbi.fsStyle & BTNS_SHOWTEXT) == BTNS_SHOWTEXT) { - SendMessage ( - lpnmlv->nmcd.hdr.hwndFrom, - TB_GETBUTTONTEXT, - (WPARAM)lpnmlv->nmcd.dwItemSpec, - (LPARAM)text - ); + SendMessage (lpnmlv->nmcd.hdr.hwndFrom, TB_GETBUTTONTEXT, (WPARAM)lpnmlv->nmcd.dwItemSpec, (LPARAM)text); if (tbi.iImage != I_IMAGENONE) lpnmlv->nmcd.rc.left += icon_size_x; @@ -1762,6 +1753,8 @@ VOID _app_displayinfoapp_callback ( PR_STRING string; LONG icon_id; + icon_id = 0; + // set text if (lpnmlv->item.mask & LVIF_TEXT) { @@ -1928,9 +1921,7 @@ VOID _app_displayinforule_callback ( // set image if (lpnmlv->item.mask & LVIF_IMAGE) - { lpnmlv->item.iImage = (ptr_rule->action == FWP_ACTION_BLOCK) ? 1 : 0; - } // set group id if (lpnmlv->item.mask & LVIF_GROUPID) @@ -1977,6 +1968,8 @@ VOID _app_displayinfonetwork_callback ( LPCWSTR name; LONG icon_id; + icon_id = 0; + // set text if (lpnmlv->item.mask & LVIF_TEXT) { @@ -2012,11 +2005,7 @@ VOID _app_displayinfonetwork_callback ( case 1: { - string = InterlockedCompareExchangePointer ( - &ptr_network->local_addr_str, - NULL, - NULL - ); + string = InterlockedCompareExchangePointer (&ptr_network->local_addr_str, NULL, NULL); if (string) _r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer); @@ -2026,11 +2015,7 @@ VOID _app_displayinfonetwork_callback ( case 2: { - string = InterlockedCompareExchangePointer ( - &ptr_network->local_host_str, - NULL, - NULL - ); + string = InterlockedCompareExchangePointer (&ptr_network->local_host_str, NULL, NULL); if (string) { @@ -2062,11 +2047,7 @@ VOID _app_displayinfonetwork_callback ( case 4: { - string = InterlockedCompareExchangePointer ( - &ptr_network->remote_addr_str, - NULL, - NULL - ); + string = InterlockedCompareExchangePointer (&ptr_network->remote_addr_str, NULL, NULL); if (string) _r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer); @@ -2076,11 +2057,7 @@ VOID _app_displayinfonetwork_callback ( case 5: { - string = InterlockedCompareExchangePointer ( - &ptr_network->remote_host_str, - NULL, - NULL - ); + string = InterlockedCompareExchangePointer (&ptr_network->remote_host_str, NULL, NULL); if (string) { @@ -2177,6 +2154,8 @@ VOID _app_displayinfolog_callback ( PR_STRING string; LONG icon_id; + icon_id = 0; + // set text if (lpnmlv->item.mask & LVIF_TEXT) { @@ -2225,11 +2204,7 @@ VOID _app_displayinfolog_callback ( case 2: { - string = InterlockedCompareExchangePointer ( - &ptr_log->local_addr_str, - NULL, - NULL - ); + string = InterlockedCompareExchangePointer (&ptr_log->local_addr_str, NULL, NULL); if (string) _r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer); @@ -2239,11 +2214,7 @@ VOID _app_displayinfolog_callback ( case 3: { - string = InterlockedCompareExchangePointer ( - &ptr_log->local_host_str, - NULL, - NULL - ); + string = InterlockedCompareExchangePointer (&ptr_log->local_host_str, NULL, NULL); if (string) { @@ -2275,11 +2246,7 @@ VOID _app_displayinfolog_callback ( case 5: { - string = InterlockedCompareExchangePointer ( - &ptr_log->remote_addr_str, - NULL, - NULL - ); + string = InterlockedCompareExchangePointer (&ptr_log->remote_addr_str, NULL, NULL); if (string) _r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, string->buffer); @@ -2289,11 +2256,7 @@ VOID _app_displayinfolog_callback ( case 6: { - string = InterlockedCompareExchangePointer ( - &ptr_log->remote_host_str, - NULL, - NULL - ); + string = InterlockedCompareExchangePointer (&ptr_log->remote_host_str, NULL, NULL); if (string) { @@ -2413,7 +2376,8 @@ BOOLEAN _app_message_displayinfo ( return TRUE; } } - else if (listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM || listview_id == IDC_APP_RULES_ID) + else if (listview_id >= IDC_RULES_BLOCKLIST && listview_id <= IDC_RULES_CUSTOM || + listview_id == IDC_APP_RULES_ID) { ptr_rule = _app_getrulebyid (index); @@ -2671,7 +2635,7 @@ VOID _app_command_logclear ( log_path = _r_config_getstringexpand (L"LogPath", LOG_PATH_DEFAULT); - current_handle = InterlockedCompareExchangePointer (&config.hlogfile,NULL,NULL); + current_handle = InterlockedCompareExchangePointer (&config.hlogfile, NULL, NULL); is_valid = (current_handle && _r_fs_getsize (current_handle) > 2) || (log_path && _r_fs_exists (log_path->buffer)); @@ -3077,9 +3041,7 @@ VOID _app_command_delete ( apps_checker = _r_obj_createhashtable (sizeof (SHORT), NULL); if (!_r_obj_isarrayempty (ptr_rule->guids)) - { _r_obj_addarrayitems (guids, ptr_rule->guids->items, ptr_rule->guids->count); - } enum_key = 0; @@ -3259,13 +3221,7 @@ VOID _app_command_openeditor ( { if (!_app_isappfound (ptr_network->app_hash)) { - ptr_network->app_hash = _app_addapplication ( - hwnd, - DATA_UNKNOWN, - ptr_network->path, - NULL, - NULL - ); + ptr_network->app_hash = _app_addapplication (hwnd, DATA_UNKNOWN, ptr_network->path, NULL, NULL); if (ptr_network->app_hash) { @@ -3322,13 +3278,7 @@ VOID _app_command_openeditor ( { if (!_app_isappfound (ptr_log->app_hash)) { - ptr_log->app_hash = _app_addapplication ( - hwnd, - DATA_UNKNOWN, - ptr_log->path, - NULL, - NULL - ); + ptr_log->app_hash = _app_addapplication (hwnd, DATA_UNKNOWN, ptr_log->path, NULL, NULL); if (ptr_log->app_hash) { @@ -3472,13 +3422,7 @@ VOID _app_command_properties ( { if (!_app_isappfound (ptr_network->app_hash)) { - ptr_network->app_hash = _app_addapplication ( - hwnd, - DATA_UNKNOWN, - ptr_network->path, - NULL, - NULL - ); + ptr_network->app_hash = _app_addapplication (hwnd, DATA_UNKNOWN, ptr_network->path, NULL, NULL); if (ptr_network->app_hash) { @@ -3506,13 +3450,7 @@ VOID _app_command_properties ( { if (!_app_isappfound (ptr_log->app_hash)) { - ptr_log->app_hash = _app_addapplication ( - hwnd, - DATA_UNKNOWN, - ptr_log->path, - NULL, - NULL - ); + ptr_log->app_hash = _app_addapplication (hwnd, DATA_UNKNOWN, ptr_log->path, NULL, NULL); if (ptr_log->app_hash) { diff --git a/src/notifications.c b/src/notifications.c index 39fb9747..6fa03f29 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -11,11 +11,7 @@ HWND _app_notify_getwindow ( HWND current_hwnd; HWND new_hwnd; - current_hwnd = InterlockedCompareExchangePointer ( - &config.hnotification, - NULL, - NULL - ); + current_hwnd = InterlockedCompareExchangePointer (&config.hnotification, NULL, NULL); if (current_hwnd) { @@ -38,11 +34,7 @@ HWND _app_notify_getwindow ( WaitForSingleObjectEx (config.hnotify_evt, 2000, FALSE); - current_hwnd = InterlockedCompareExchangePointer ( - &config.hnotification, - NULL, - NULL - ); + current_hwnd = InterlockedCompareExchangePointer (&config.hnotification, NULL, NULL); return current_hwnd; } @@ -170,8 +162,11 @@ BOOLEAN _app_notify_addobject ( { if (_r_config_getboolean (L"IsNotificationsSound", TRUE)) { - if (!_r_config_getboolean (L"IsNotificationsFullscreenSilentMode", TRUE) || !_r_wnd_isfullscreenmode ()) + if (!_r_config_getboolean (L"IsNotificationsFullscreenSilentMode", TRUE) || + !_r_wnd_isfullscreenmode ()) + { _app_notify_playsound (); + } } return TRUE; @@ -575,11 +570,7 @@ VOID _app_notify_playsound () ULONG flags; LSTATUS status; - current_path = InterlockedCompareExchangePointer ( - &cached_path, - NULL, - NULL - ); + current_path = InterlockedCompareExchangePointer (&cached_path, NULL, NULL); if (!current_path || !_r_fs_exists (current_path->buffer)) { @@ -602,11 +593,7 @@ VOID _app_notify_playsound () if (expanded_string) _r_obj_movereference (&new_path, expanded_string); - current_path = InterlockedCompareExchangePointer ( - &cached_path, - new_path, - current_path - ); + current_path = InterlockedCompareExchangePointer (&cached_path, new_path, current_path); if (current_path) _r_obj_dereference (new_path); @@ -819,37 +806,10 @@ VOID _app_notify_initialize ( context->hbmp_rules = _app_bitmapfrompng (NULL, MAKEINTRESOURCE (IDP_SETTINGS), icon_small); // set button configuration - SendDlgItemMessage ( - context->hwnd, - IDC_RULES_BTN, - BM_SETIMAGE, - IMAGE_BITMAP, - (LPARAM)context->hbmp_rules - ); - - SendDlgItemMessage ( - context->hwnd, - IDC_ALLOW_BTN, - BM_SETIMAGE, - IMAGE_BITMAP, - (LPARAM)context->hbmp_allow - ); - - SendDlgItemMessage ( - context->hwnd, - IDC_BLOCK_BTN, - BM_SETIMAGE, - IMAGE_BITMAP, - (LPARAM)context->hbmp_block - ); - - SendDlgItemMessage ( - context->hwnd, - IDC_LATER_BTN, - BM_SETIMAGE, - IMAGE_BITMAP, - (LPARAM)context->hbmp_cross - ); + SendDlgItemMessage (context->hwnd, IDC_RULES_BTN, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)context->hbmp_rules); + SendDlgItemMessage (context->hwnd, IDC_ALLOW_BTN, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)context->hbmp_allow); + SendDlgItemMessage (context->hwnd, IDC_BLOCK_BTN, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)context->hbmp_block); + SendDlgItemMessage (context->hwnd, IDC_LATER_BTN, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)context->hbmp_cross); _r_ctrl_setbuttonmargins (context->hwnd, IDC_RULES_BTN, dpi_value); _r_ctrl_setbuttonmargins (context->hwnd, IDC_ALLOW_BTN, dpi_value); @@ -940,11 +900,7 @@ INT_PTR CALLBACK NotificationProc ( HWND htip; LONG dpi_value; - current_hwnd = InterlockedCompareExchangePointer ( - &config.hnotification, - hwnd, - config.hnotification - ); + current_hwnd = InterlockedCompareExchangePointer (&config.hnotification, hwnd, config.hnotification); if (current_hwnd) DestroyWindow (current_hwnd); @@ -993,11 +949,7 @@ INT_PTR CALLBACK NotificationProc ( case WM_NCDESTROY: { - InterlockedCompareExchangePointer ( - &config.hnotification, - NULL, - config.hnotification - ); + InterlockedCompareExchangePointer (&config.hnotification, NULL, config.hnotification); _app_notify_destroy (hwnd); @@ -1480,11 +1432,7 @@ INT_PTR CALLBACK NotificationProc ( } } - _app_listview_updateby_id ( - _r_app_gethwnd (), - DATA_LISTVIEW_CURRENT, - PR_UPDATE_TYPE - ); + _app_listview_updateby_id (_r_app_gethwnd (), DATA_LISTVIEW_CURRENT, PR_UPDATE_TYPE); _r_obj_dereference (ptr_app); _r_obj_dereference (ptr_rule); diff --git a/src/packages.c b/src/packages.c index 9d5b8ebe..a5400927 100644 --- a/src/packages.c +++ b/src/packages.c @@ -375,7 +375,6 @@ VOID _app_package_getserviceslist () static ULONG initial_buffer_size = 0x8000; SC_HANDLE hsvcmgr; - WCHAR general_key[256]; EXPLICIT_ACCESS ea; LPENUM_SERVICE_STATUS_PROCESS service; @@ -389,22 +388,16 @@ VOID _app_package_getserviceslist () ULONG service_type; ULONG service_state; ULONG sd_length; - PR_STRING name_string; PITEM_APP ptr_app; - R_STRINGREF dummy_filename; R_STRINGREF dummy_argument; PR_STRING converted_path; - PVOID buffer; ULONG buffer_size; - ULONG return_length; ULONG services_returned; - HKEY hkey; - NTSTATUS status; hsvcmgr = OpenSCManager (NULL, NULL, SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE); @@ -518,12 +511,7 @@ VOID _app_package_getserviceslist () if (service_path) { - _r_path_parsecommandlinefuzzy ( - &service_path->sr, - &dummy_filename, - &dummy_argument, - &converted_path - ); + _r_path_parsecommandlinefuzzy (&service_path->sr, &dummy_filename, &dummy_argument, &converted_path); if (converted_path) { @@ -551,13 +539,7 @@ VOID _app_package_getserviceslist () // condition evaluates to true. Likewise if it denies access, the // condition evaluates to false. - _app_setexplicitaccess ( - &ea, - GRANT_ACCESS, - FWP_ACTRL_MATCH_FILTER, - NO_INHERITANCE, - service_sid->buffer - ); + _app_setexplicitaccess (&ea, GRANT_ACCESS, FWP_ACTRL_MATCH_FILTER, NO_INHERITANCE, service_sid->buffer); // Security descriptors must be in self-relative form (i.e., contiguous). // The security descriptor returned by BuildSecurityDescriptorW is @@ -581,13 +563,7 @@ VOID _app_package_getserviceslist () { name_string = _r_obj_createstring (service->lpDisplayName); - app_hash = _app_addapplication ( - NULL, - DATA_APP_SERVICE, - service_name, - name_string, - service_path - ); + app_hash = _app_addapplication (NULL, DATA_APP_SERVICE, service_name, name_string, service_path); if (app_hash) { @@ -595,17 +571,8 @@ VOID _app_package_getserviceslist () if (ptr_app) { - _app_setappinfo ( - ptr_app, - INFO_TIMESTAMP, - &service_timestamp - ); - - _app_setappinfo ( - ptr_app, - INFO_BYTES_DATA, - _r_obj_createbyte_ex (service_sd, sd_length) - ); + _app_setappinfo (ptr_app, INFO_TIMESTAMP, &service_timestamp); + _app_setappinfo (ptr_app, INFO_BYTES_DATA, _r_obj_createbyte_ex (service_sd, sd_length)); _r_obj_dereference (ptr_app); } diff --git a/src/profile.c b/src/profile.c index 39132c39..26d4291d 100644 --- a/src/profile.c +++ b/src/profile.c @@ -757,8 +757,12 @@ VOID _app_getcount ( if (_app_istimerset (ptr_app)) status->apps_timer_count += 1; - if (!ptr_app->is_undeletable && (!_app_isappexists (ptr_app) || !is_used) && !(ptr_app->type == DATA_APP_SERVICE || ptr_app->type == DATA_APP_UWP)) + if (!ptr_app->is_undeletable && + (!_app_isappexists (ptr_app) || !is_used) && + !(ptr_app->type == DATA_APP_SERVICE || ptr_app->type == DATA_APP_UWP)) + { status->apps_unused_count += 1; + } if (is_used) status->apps_count += 1; @@ -1122,7 +1126,8 @@ PR_STRING _app_appexpandrules ( if (!ptr_rule) continue; - if (ptr_rule->is_enabled && ptr_rule->type == DATA_RULE_USER && !_r_obj_isstringempty (ptr_rule->name) && _r_obj_findhashtable (ptr_rule->apps, app_hash)) + if (ptr_rule->is_enabled && ptr_rule->type == DATA_RULE_USER && + !_r_obj_isstringempty (ptr_rule->name) && _r_obj_findhashtable (ptr_rule->apps, app_hash)) { _r_obj_appendstringbuilder2 (&buffer, ptr_rule->name); @@ -1587,7 +1592,8 @@ VOID _app_profile_load_internal ( } else { - is_loadfromresource = (db_info_file.version < db_info_buffer->version) || (db_info_file.timestamp < db_info_buffer->timestamp); + is_loadfromresource = (db_info_file.version < db_info_buffer->version) || + (db_info_file.timestamp < db_info_buffer->timestamp); } db_info = is_loadfromresource ? db_info_buffer : &db_info_file; @@ -1706,7 +1712,14 @@ CleanupExit: { // load internal rules (new!) if (!_r_config_getboolean (L"IsInternalRulesDisabled", FALSE)) - _app_profile_load_internal (hwnd, profile_info.profile_path_internal, MAKEINTRESOURCE (IDR_PROFILE_INTERNAL), &profile_info.profile_internal_timestamp); + { + _app_profile_load_internal ( + hwnd, + profile_info.profile_path_internal, + MAKEINTRESOURCE (IDR_PROFILE_INTERNAL), + &profile_info.profile_internal_timestamp + ); + } _app_profile_load_fallback (); @@ -1745,8 +1758,12 @@ NTSTATUS _app_profile_save () if (!is_backuprequired) { - if ((timestamp - _r_config_getlong64 (L"BackupTimestamp", 0)) >= _r_config_getlong64 (L"BackupPeriod", BACKUP_HOURS_PERIOD)) + if ((timestamp - _r_config_getlong64 ( + L"BackupTimestamp", 0)) >= + _r_config_getlong64 (L"BackupPeriod", BACKUP_HOURS_PERIOD)) + { is_backuprequired = TRUE; + } } } diff --git a/src/search.c b/src/search.c index 4443840e..c6e3b8a0 100644 --- a/src/search.c +++ b/src/search.c @@ -29,13 +29,7 @@ VOID _app_search_initializetheme ( if (htheme) { - hr = GetThemeInt ( - htheme, - EP_EDITBORDER_NOSCROLL, - EPSHV_NORMAL, - TMT_BORDERSIZE, - &context->cx_border - ); + hr = GetThemeInt (htheme, EP_EDITBORDER_NOSCROLL, EPSHV_NORMAL, TMT_BORDERSIZE, &context->cx_border); if (!SUCCEEDED (hr)) context->cx_border = 0; @@ -170,29 +164,9 @@ VOID _app_search_drawbutton ( _r_dc_fillrect (buffer_dc, &rect, GetSysColor (COLOR_WINDOW)); } - DrawIconEx ( - buffer_dc, - rect.left + 1, - rect.top, - context->hicon, - context->image_width, - context->image_height, - 0, - NULL, - DI_NORMAL - ); + DrawIconEx (buffer_dc, rect.left + 1, rect.top, context->hicon, context->image_width, context->image_height, 0, NULL, DI_NORMAL); - BitBlt ( - hdc, - button_rect->left, - button_rect->top, - button_rect->right, - button_rect->bottom, - buffer_dc, - 0, - 0, - SRCCOPY - ); + BitBlt (hdc, button_rect->left, button_rect->top, button_rect->right, button_rect->bottom, buffer_dc, 0, 0, SRCCOPY); SelectObject (buffer_dc, old_bitmap); DeleteObject (buffer_bitmap); @@ -667,14 +641,14 @@ LRESULT CALLBACK _app_search_subclass_proc ( _app_search_getbuttonrect (context, &rect); // Check that the mouse is within the inserted button. - if (PtInRect (&rect, point)) - { - context->is_pushed = TRUE; + if (!PtInRect (&rect, point)) + break; - SetCapture (hwnd); + context->is_pushed = TRUE; - RedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); - } + SetCapture (hwnd); + + RedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); break; } @@ -771,21 +745,21 @@ LRESULT CALLBACK _app_search_subclass_proc ( _app_search_getbuttonrect (context, &rect); // Check that the mouse is within the inserted button. - if (PtInRect (&rect, point) && !context->is_hot) - { - ZeroMemory (&tme, sizeof (tme)); + if (!PtInRect (&rect, point) && !context->is_hot) + break; - tme.cbSize = sizeof (tme); - tme.dwFlags = TME_LEAVE | TME_NONCLIENT; - tme.hwndTrack = hwnd; - tme.dwHoverTime = 0; + RtlZeroMemory (&tme, sizeof (tme)); - context->is_hot = TRUE; + tme.cbSize = sizeof (tme); + tme.dwFlags = TME_LEAVE | TME_NONCLIENT; + tme.hwndTrack = hwnd; + tme.dwHoverTime = 0; - RedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); + context->is_hot = TRUE; - TrackMouseEvent (&tme); - } + RedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); + + TrackMouseEvent (&tme); break; } @@ -793,10 +767,10 @@ LRESULT CALLBACK _app_search_subclass_proc ( case WM_NCMOUSELEAVE: { if (!context->is_hot) - break; + break; - context->is_hot = FALSE; - RedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); + context->is_hot = FALSE; + RedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); break; } @@ -806,24 +780,24 @@ LRESULT CALLBACK _app_search_subclass_proc ( POINT point; RECT rect; - if ((wparam & MK_LBUTTON) && GetCapture () == hwnd) - { - // Get the screen coordinates of the mouse. - if (!GetCursorPos (&point)) - break; + if (!(wparam & MK_LBUTTON) && GetCapture () != hwnd) + break; - // Get the screen coordinates of the window. - if (!GetWindowRect (hwnd, &rect)) - break; + // Get the screen coordinates of the mouse. + if (!GetCursorPos (&point)) + break; - // Get the position of the inserted button. - _app_search_getbuttonrect (context, &rect); + // Get the screen coordinates of the window. + if (!GetWindowRect (hwnd, &rect)) + break; - // Check that the mouse is within the inserted button. - context->is_pushed = PtInRect (&rect, point); + // Get the position of the inserted button. + _app_search_getbuttonrect (context, &rect); - RedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); - } + // Check that the mouse is within the inserted button. + context->is_pushed = PtInRect (&rect, point); + + RedrawWindow (hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); break; } diff --git a/src/security.c b/src/security.c index be6348e5..55dba9ce 100644 --- a/src/security.c +++ b/src/security.c @@ -96,12 +96,9 @@ PACL _app_createaccesscontrollist ( EXPLICIT_ACCESS ea[3] = {0}; PACL new_dacl; PACCESS_ALLOWED_ACE ace; - BOOLEAN is_secured = FALSE; - BOOLEAN is_currentuserhaverights = FALSE; BOOLEAN is_openforeveryone = FALSE; - ULONG count; ULONG status; @@ -153,27 +150,11 @@ PACL _app_createaccesscontrollist ( // revoke current user access rights if (is_currentuserhaverights) - { - _app_setexplicitaccess ( - &ea[count++], - REVOKE_ACCESS, - 0, - NO_INHERITANCE, - config.pbuiltin_current_sid - ); - } + _app_setexplicitaccess (&ea[count++], REVOKE_ACCESS, 0, NO_INHERITANCE, config.pbuiltin_current_sid); // revoke everyone access rights if (is_openforeveryone) - { - _app_setexplicitaccess ( - &ea[count++], - REVOKE_ACCESS, - 0, - NO_INHERITANCE, - &SeEveryoneSid - ); - } + _app_setexplicitaccess (&ea[count++], REVOKE_ACCESS, 0, NO_INHERITANCE, &SeEveryoneSid); // secure filter from deletion _app_setexplicitaccess ( @@ -307,15 +288,7 @@ VOID _app_setsecurityinfoforengine ( if (is_currentuserhaverights) { if (config.pbuiltin_current_sid) - { - _app_setexplicitaccess ( - &ea[count++], - REVOKE_ACCESS, - 0, - NO_INHERITANCE, - config.pbuiltin_current_sid - ); - } + _app_setexplicitaccess (&ea[count++], REVOKE_ACCESS, 0, NO_INHERITANCE, config.pbuiltin_current_sid); } // reset default engine rights diff --git a/src/wfp.c b/src/wfp.c index 5fafdeee..a921e741 100644 --- a/src/wfp.c +++ b/src/wfp.c @@ -1104,33 +1104,25 @@ BOOLEAN _wfp_createrulefilter ( { FWPM_FILTER_CONDITION fwfc[8] = {0}; UINT32 count = 0; - ITEM_ADDRESS address; - FWP_V4_ADDR_AND_MASK fwp_addr4_and_mask1; FWP_V4_ADDR_AND_MASK fwp_addr4_and_mask2; - FWP_V6_ADDR_AND_MASK fwp_addr6_and_mask1; FWP_V6_ADDR_AND_MASK fwp_addr6_and_mask2; - FWP_RANGE fwp_range1; FWP_RANGE fwp_range2; - FWP_BYTE_BLOB *byte_blob = NULL; PITEM_APP ptr_app = NULL; BOOLEAN is_remoteaddr_set = FALSE; BOOLEAN is_remoteport_set = FALSE; BOOLEAN is_success = FALSE; - FWP_DIRECTION direction; UINT8 protocol; ADDRESS_FAMILY af; - PR_STRINGREF rules[] = { rule_remote, rule_local }; - NTSTATUS status; if (filter_config) @@ -1810,8 +1802,6 @@ BOOLEAN _wfp_create3filters ( _In_ BOOLEAN is_intransact ) { - if (_r_obj_islistempty (rules)) - return FALSE; PR_ARRAY guids; LPCGUID guid; @@ -1820,6 +1810,9 @@ BOOLEAN _wfp_create3filters ( BOOLEAN is_enabled; BOOLEAN is_secure; + if (_r_obj_islistempty (rules)) + return FALSE; + if (!is_intransact && _wfp_isfiltersapplying ()) is_intransact = TRUE; @@ -2797,13 +2790,7 @@ ULONG _wfp_dumpcallouts ( callouts_enum = NULL; guids = NULL; - status = FwpmCalloutEnum ( - engine_handle, - enum_handle, - UINT32_MAX, - &callouts_enum, - &return_count - ); + status = FwpmCalloutEnum (engine_handle, enum_handle, UINT32_MAX, &callouts_enum, &return_count); if (status != ERROR_SUCCESS) goto CleanupExit;