From 1f912750526e9bcfdd49ea202d229751335a0d4b Mon Sep 17 00:00:00 2001 From: henrypp Date: Mon, 10 May 2021 21:09:02 +0600 Subject: [PATCH] use ULONG_PTR for hash --- src/editor.c | 2 +- src/helper.c | 26 +++++++++---------- src/helper.h | 8 +++--- src/main.c | 11 +++++--- src/main.h | 16 ++++++------ src/messages.c | 26 +++++++++---------- src/notifications.c | 18 +++++++------ src/notifications.h | 4 +-- src/profile.c | 62 +++++++++++++++++++++++++-------------------- src/profile.h | 30 +++++++++++----------- src/timer.c | 2 +- src/wfp.c | 6 ++--- src/wfp.h | 2 +- 13 files changed, 112 insertions(+), 101 deletions(-) diff --git a/src/editor.c b/src/editor.c index d87f13a3..f51a8d29 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1379,7 +1379,7 @@ INT_PTR CALLBACK PropertiesProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar if (!_r_listview_isitemchecked (hpage_apps, IDC_RULE_APPS_ID, i)) continue; - SIZE_T app_hash = _r_listview_getitemlparam (hpage_apps, IDC_RULE_APPS_ID, i); + ULONG_PTR app_hash = _r_listview_getitemlparam (hpage_apps, IDC_RULE_APPS_ID, i); if (context->ptr_rule->is_forservices && (app_hash == config.ntoskrnl_hash || app_hash == config.svchost_hash)) continue; diff --git a/src/helper.c b/src/helper.c index 2ef2829f..4707ca6e 100644 --- a/src/helper.c +++ b/src/helper.c @@ -58,7 +58,7 @@ VOID NTAPI _app_dereferencerule (_In_ PVOID entry) } _Ret_maybenull_ -PR_HASHSTORE _app_addcachetablevalue (_Inout_ PR_HASHTABLE hashtable, _In_ SIZE_T hash_code, _In_opt_ PR_STRING string, _In_opt_ LONG number) +PR_HASHSTORE _app_addcachetablevalue (_Inout_ PR_HASHTABLE hashtable, _In_ ULONG_PTR hash_code, _In_opt_ PR_STRING string, _In_opt_ LONG number) { R_HASHSTORE hashstore; PR_HASHSTORE result; @@ -71,7 +71,7 @@ PR_HASHSTORE _app_addcachetablevalue (_Inout_ PR_HASHTABLE hashtable, _In_ SIZE_ } _Ret_maybenull_ -PR_HASHSTORE _app_addcachetable (_Inout_ PR_HASHTABLE hashtable, _In_ SIZE_T hash_code, _In_ PR_SPINLOCK spin_lock, _In_opt_ PR_STRING string, _In_opt_ LONG number) +PR_HASHSTORE _app_addcachetable (_Inout_ PR_HASHTABLE hashtable, _In_ ULONG_PTR hash_code, _In_ PR_SPINLOCK spin_lock, _In_opt_ PR_STRING string, _In_opt_ LONG number) { PR_HASHSTORE result; @@ -82,7 +82,7 @@ PR_HASHSTORE _app_addcachetable (_Inout_ PR_HASHTABLE hashtable, _In_ SIZE_T has { PR_HASHSTORE hashtable_entry; SIZE_T enum_key = 0; - SIZE_T hashtable_hash; + ULONG_PTR hashtable_hash; if (!_r_obj_enumhashtable (hashtable, &hashtable_entry, &hashtable_hash, &enum_key)) break; @@ -102,7 +102,7 @@ PR_HASHSTORE _app_addcachetable (_Inout_ PR_HASHTABLE hashtable, _In_ SIZE_T has } _Ret_maybenull_ -PR_HASHSTORE _app_getcachetable (_Inout_ PR_HASHTABLE cache_table, _In_ SIZE_T hash_code, _In_ PR_SPINLOCK spin_lock) +PR_HASHSTORE _app_getcachetable (_Inout_ PR_HASHTABLE cache_table, _In_ ULONG_PTR hash_code, _In_ PR_SPINLOCK spin_lock) { PR_HASHSTORE hashstore; @@ -207,7 +207,7 @@ PR_STRING _app_formataddress (_In_ ADDRESS_FAMILY af, _In_ UINT8 proto, _In_ LPC if (is_success && _r_config_getboolean (L"IsNetworkResolutionsEnabled", FALSE)) { PR_STRING domain_string = NULL; - SIZE_T addr_hash; + ULONG_PTR addr_hash; PR_HASHSTORE hashstore; addr_hash = _r_str_hash (formatted_address); @@ -1642,7 +1642,7 @@ PR_STRING _app_getnetworkpath (ULONG pid, PULONG64 pmodules, PITEM_NETWORK ptr_n if (!_r_obj_isstringempty (process_name)) { - SIZE_T app_hash = _r_obj_getstringhash (process_name); + ULONG_PTR app_hash = _r_obj_getstringhash (process_name); ptr_network->app_hash = app_hash; ptr_network->icon_id = PtrToInt (_app_getappinfobyhash (app_hash, InfoIconId)); @@ -1659,12 +1659,12 @@ PR_STRING _app_getnetworkpath (ULONG pid, PULONG64 pmodules, PITEM_NETWORK ptr_n return process_name; } -SIZE_T _app_getnetworkhash (ADDRESS_FAMILY af, ULONG pid, LPCVOID remote_addr, ULONG remote_port, LPCVOID local_addr, ULONG local_port, UINT8 proto, ULONG state) +ULONG_PTR _app_getnetworkhash (ADDRESS_FAMILY af, ULONG pid, LPCVOID remote_addr, ULONG remote_port, LPCVOID local_addr, ULONG local_port, UINT8 proto, ULONG state) { WCHAR remote_address[LEN_IP_MAX] = {0}; WCHAR local_address[LEN_IP_MAX] = {0}; PR_STRING network_string; - SIZE_T network_hash; + ULONG_PTR network_hash; if (remote_addr) _app_formatip (af, remote_addr, remote_address, RTL_NUMBER_OF (remote_address), FALSE); @@ -1983,7 +1983,7 @@ VOID _app_generate_packages () PR_STRING display_name; PR_STRING real_path; PITEM_APP ptr_app; - SIZE_T app_hash; + ULONG_PTR app_hash; HKEY hkey; HKEY hsubkey; ULONG key_index; @@ -2143,8 +2143,8 @@ VOID _app_generate_services () LPENUM_SERVICE_STATUS_PROCESS service; LPENUM_SERVICE_STATUS_PROCESS services; PITEM_APP ptr_app; + ULONG_PTR app_hash; HKEY hkey; - SIZE_T app_hash; PVOID service_sd; ULONG sd_length; @@ -2270,7 +2270,7 @@ VOID _app_generate_services () CloseServiceHandle (hsvcmgr); } -VOID _app_generate_rulescontrol (_In_ HMENU hsubmenu, _In_opt_ SIZE_T app_hash) +VOID _app_generate_rulescontrol (_In_ HMENU hsubmenu, _In_opt_ ULONG_PTR app_hash) { ITEM_STATUS status; @@ -2631,7 +2631,7 @@ BOOLEAN _app_parsenetworkstring (_In_ LPCWSTR network_string, _Inout_ PITEM_ADDR } else if (ni.Format == NET_ADDRESS_DNS_NAME) { - SIZE_T dns_hash; + ULONG_PTR dns_hash; PR_HASHSTORE hashstore; dns_hash = _r_str_hash (ni.NamedAddress.Address); @@ -2808,7 +2808,7 @@ BOOLEAN _app_parserulestring (_In_opt_ PR_STRING rule, _Inout_opt_ PITEM_ADDRESS } // auto-parse rule type - SIZE_T rule_hash; + ULONG_PTR rule_hash; PR_HASHSTORE hashstore; rule_hash = _r_obj_getstringhash (rule); diff --git a/src/helper.h b/src/helper.h index d115260b..778ea568 100644 --- a/src/helper.h +++ b/src/helper.h @@ -16,13 +16,13 @@ VOID NTAPI _app_dereferencelog (_In_ PVOID entry); VOID NTAPI _app_dereferencerule (_In_ PVOID entry); _Ret_maybenull_ -PR_HASHSTORE _app_addcachetablevalue (_Inout_ PR_HASHTABLE hashtable, _In_ SIZE_T hash_code, _In_opt_ PR_STRING string, _In_opt_ LONG number); +PR_HASHSTORE _app_addcachetablevalue (_Inout_ PR_HASHTABLE hashtable, _In_ ULONG_PTR hash_code, _In_opt_ PR_STRING string, _In_opt_ LONG number); _Ret_maybenull_ -PR_HASHSTORE _app_addcachetable (_Inout_ PR_HASHTABLE hashtable, _In_ SIZE_T hash_code, _In_ PR_SPINLOCK spin_lock, _In_opt_ PR_STRING string, _In_opt_ LONG number); +PR_HASHSTORE _app_addcachetable (_Inout_ PR_HASHTABLE hashtable, _In_ ULONG_PTR hash_code, _In_ PR_SPINLOCK spin_lock, _In_opt_ PR_STRING string, _In_opt_ LONG number); _Ret_maybenull_ -PR_HASHSTORE _app_getcachetable (_Inout_ PR_HASHTABLE cache_table, _In_ SIZE_T hash_code, _In_ PR_SPINLOCK spin_lock); +PR_HASHSTORE _app_getcachetable (_Inout_ PR_HASHTABLE cache_table, _In_ ULONG_PTR hash_code, _In_ PR_SPINLOCK spin_lock); _Ret_maybenull_ PR_STRING _app_resolveaddress (_In_ ADDRESS_FAMILY af, _In_ LPCVOID address); @@ -67,7 +67,7 @@ VOID _app_generate_connections (_Inout_ PR_HASHTABLE checker_map); VOID _app_generate_packages (); VOID _app_generate_services (); -VOID _app_generate_rulescontrol (_In_ HMENU hsubmenu, _In_opt_ SIZE_T app_hash); +VOID _app_generate_rulescontrol (_In_ HMENU hsubmenu, _In_opt_ ULONG_PTR app_hash); VOID _app_generate_timerscontrol (_In_ HMENU hsubmenu, _In_opt_ PITEM_APP ptr_app); BOOLEAN _app_setruletoapp (_In_ HWND hwnd, _Inout_ PITEM_RULE ptr_rule, _In_ INT item_id, _In_ PITEM_APP ptr_app, _In_ BOOLEAN is_enable); diff --git a/src/main.c b/src/main.c index 4cd25f00..922e2c11 100644 --- a/src/main.c +++ b/src/main.c @@ -157,16 +157,19 @@ THREAD_API NetworkMonitorThread (_In_ PVOID lparam) if (item_count) { + ULONG_PTR network_hash; + ULONG_PTR app_hash; + for (INT i = item_count - 1; i != -1; i--) { - SIZE_T network_hash = _r_listview_getitemlparam (hwnd, network_listview_id, i); + network_hash = _r_listview_getitemlparam (hwnd, network_listview_id, i); if (_r_obj_findhashtable (checker_map, network_hash)) continue; _r_listview_deleteitem (hwnd, network_listview_id, i); - SIZE_T app_hash = _app_getnetworkapp (network_hash); + app_hash = _app_getnetworkapp (network_hash); _r_spinlock_acquireexclusive (&lock_network); @@ -2273,7 +2276,7 @@ INT_PTR CALLBACK DlgProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wparam, _In if (listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP) { - SIZE_T app_hash = lpnmlv->lParam; + ULONG_PTR app_hash = lpnmlv->lParam; PITEM_APP ptr_app = _app_getappitem (app_hash); if (!ptr_app) @@ -3199,7 +3202,7 @@ INT_PTR CALLBACK DlgProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wparam, _In { while ((item = (INT)SendDlgItemMessage (hwnd, listview_id, LVM_GETNEXTITEM, (WPARAM)item, LVNI_SELECTED)) != -1) { - SIZE_T app_hash = _r_listview_getitemlparam (hwnd, listview_id, item); + ULONG_PTR app_hash = _r_listview_getitemlparam (hwnd, listview_id, item); PITEM_APP ptr_app = _app_getappitem (app_hash); if (ptr_app) diff --git a/src/main.h b/src/main.h index eff85b2b..4790e133 100644 --- a/src/main.h +++ b/src/main.h @@ -238,9 +238,9 @@ typedef struct tagSTATIC_DATA LONG64 profile_internal_timestamp; - SIZE_T ntoskrnl_hash; - SIZE_T svchost_hash; - SIZE_T my_hash; + ULONG_PTR ntoskrnl_hash; + ULONG_PTR svchost_hash; + ULONG_PTR my_hash; SIZE_T wd_length; @@ -278,7 +278,7 @@ typedef struct tagITEM_LOG UINT64 filter_id; - SIZE_T app_hash; + ULONG_PTR app_hash; FWP_DIRECTION direction; @@ -315,7 +315,7 @@ typedef struct tagITEM_APP LONG64 timer; LONG64 last_notify; - SIZE_T app_hash; + ULONG_PTR app_hash; INT icon_id; @@ -381,8 +381,8 @@ typedef struct tagITEM_NETWORK }; PR_STRING path; - SIZE_T app_hash; - SIZE_T network_hash; + ULONG_PTR app_hash; + ULONG_PTR network_hash; ULONG state; INT icon_id; FWP_DIRECTION direction; @@ -439,7 +439,7 @@ typedef struct tagITEM_COLOR { PR_STRING config_name; PR_STRING config_value; - SIZE_T hash; + ULONG_PTR hash; COLORREF default_clr; COLORREF new_clr; UINT locale_id; diff --git a/src/messages.c b/src/messages.c index 1d46119b..a038798d 100644 --- a/src/messages.c +++ b/src/messages.c @@ -15,7 +15,7 @@ VOID _app_message_contextmenu (_In_ HWND hwnd, _In_ LPNMITEMACTIVATE lpnmlv) PR_STRING localized_string; PR_STRING column_text; - SIZE_T hash_item; + ULONG_PTR hash_item; INT listview_id; INT lv_column_current; @@ -952,7 +952,7 @@ VOID _app_command_idtorules (_In_ HWND hwnd, _In_ INT ctrl_id) while ((item_id = (INT)SendDlgItemMessage (hwnd, listview_id, LVM_GETNEXTITEM, (WPARAM)item_id, LVNI_SELECTED)) != -1) { - SIZE_T app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); + ULONG_PTR app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); if (ptr_rule->is_forservices && (app_hash == config.ntoskrnl_hash || app_hash == config.svchost_hash)) continue; @@ -1014,7 +1014,7 @@ VOID _app_command_idtotimers (_In_ HWND hwnd, _In_ INT ctrl_id) while ((item_id = (INT)SendDlgItemMessage (hwnd, listview_id, LVM_GETNEXTITEM, (WPARAM)item_id, LVNI_SELECTED)) != -1) { - SIZE_T app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); + ULONG_PTR app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); PITEM_APP ptr_app = _app_getappitem (app_hash); if (ptr_app) @@ -1248,7 +1248,7 @@ VOID _app_command_checkbox (_In_ HWND hwnd, _In_ INT ctrl_id) { while ((item_id = (INT)SendDlgItemMessage (hwnd, listview_id, LVM_GETNEXTITEM, (WPARAM)item_id, LVNI_SELECTED)) != -1) { - SIZE_T app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); + ULONG_PTR app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); PITEM_APP ptr_app = _app_getappitem (app_hash); if (!ptr_app) @@ -1375,7 +1375,7 @@ VOID _app_command_delete (_In_ HWND hwnd) if (listview_id == IDC_APPS_PROFILE) { - SIZE_T app_hash = _r_listview_getitemlparam (hwnd, listview_id, i); + ULONG_PTR app_hash = _r_listview_getitemlparam (hwnd, listview_id, i); PITEM_APP ptr_app = _app_getappitem (app_hash); if (!ptr_app) @@ -1401,7 +1401,7 @@ VOID _app_command_delete (_In_ HWND hwnd) PR_HASHTABLE apps_checker; PR_HASHSTORE hashstore; PITEM_APP ptr_app; - SIZE_T hash_code; + ULONG_PTR hash_code; SIZE_T enum_key = 0; if (!ptr_rule) @@ -1450,7 +1450,7 @@ VOID _app_command_delete (_In_ HWND hwnd) } else if (listview_id == IDC_NETWORK) { - SIZE_T network_hash = _r_listview_getitemlparam (hwnd, listview_id, i); + ULONG_PTR network_hash = _r_listview_getitemlparam (hwnd, listview_id, i); PITEM_NETWORK ptr_network = _app_getnetworkitem (network_hash); if (!ptr_network) @@ -1517,7 +1517,7 @@ VOID _app_command_disable (_In_ HWND hwnd, _In_ INT ctrl_id) while ((item_id = (INT)SendDlgItemMessage (hwnd, listview_id, LVM_GETNEXTITEM, (WPARAM)item_id, LVNI_SELECTED)) != -1) { - SIZE_T app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); + ULONG_PTR app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); PITEM_APP ptr_app = _app_getappitem (app_hash); if (!ptr_app) @@ -1563,7 +1563,7 @@ VOID _app_command_openeditor (_In_ HWND hwnd) while ((item_id = (INT)SendDlgItemMessage (hwnd, listview_id, LVM_GETNEXTITEM, (WPARAM)item_id, LVNI_SELECTED)) != -1) { - SIZE_T app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); + ULONG_PTR app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); if (_app_getappitem (app_hash)) { @@ -1579,7 +1579,7 @@ VOID _app_command_openeditor (_In_ HWND hwnd) if (item_id != -1) { - SIZE_T network_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); + ULONG_PTR network_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); PITEM_NETWORK ptr_network = _app_getnetworkitem (network_hash); if (ptr_network) @@ -1701,7 +1701,7 @@ VOID _app_command_properties (_In_ HWND hwnd) if (listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP) { ITEM_CONTEXT context = {0}; - SIZE_T app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); + ULONG_PTR app_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); PITEM_APP ptr_app = _app_getappitem (app_hash); if (!ptr_app) @@ -1748,7 +1748,7 @@ VOID _app_command_properties (_In_ HWND hwnd) } else if (listview_id == IDC_NETWORK) { - SIZE_T network_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); + ULONG_PTR network_hash = _r_listview_getitemlparam (hwnd, listview_id, item_id); PITEM_NETWORK ptr_network = _app_getnetworkitem (network_hash); if (!ptr_network) @@ -1851,7 +1851,7 @@ VOID _app_command_purgeunused (_In_ HWND hwnd) for (SIZE_T i = 0; i < _r_obj_getarraysize (apps_list); i++) { - PSIZE_T hash = _r_obj_getarrayitem (apps_list, i); + PULONG_PTR hash = _r_obj_getarrayitem (apps_list, i); if (hash) { diff --git a/src/notifications.c b/src/notifications.c index 1616123c..1ee0222f 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -14,7 +14,7 @@ VOID _app_notifycreatewindow () BOOLEAN _app_notifycommand (_In_ HWND hwnd, _In_ INT button_id, _In_ LONG64 seconds) { - SIZE_T app_hash = _app_notifyget_id (hwnd, FALSE); + ULONG_PTR app_hash = _app_notifyget_id (hwnd, FALSE); PITEM_APP ptr_app = _app_getappitem (app_hash); if (!ptr_app) @@ -123,9 +123,9 @@ VOID _app_freenotify (_Inout_ PITEM_APP ptr_app) _app_notifyrefresh (hwnd, TRUE); } -SIZE_T _app_notifyget_id (_In_ HWND hwnd, _In_ BOOLEAN is_nearest) +ULONG_PTR _app_notifyget_id (_In_ HWND hwnd, _In_ BOOLEAN is_nearest) { - SIZE_T app_hash_current = (SIZE_T)GetWindowLongPtr (hwnd, GWLP_USERDATA); + ULONG_PTR app_hash_current = (ULONG_PTR)GetWindowLongPtr (hwnd, GWLP_USERDATA); if (is_nearest) { @@ -159,9 +159,11 @@ SIZE_T _app_notifyget_id (_In_ HWND hwnd, _In_ BOOLEAN is_nearest) return app_hash_current; } -PITEM_LOG _app_notifyget_obj (_In_ SIZE_T app_hash) +PITEM_LOG _app_notifyget_obj (_In_ ULONG_PTR app_hash) { - PITEM_APP ptr_app = _app_getappitem (app_hash); + PITEM_APP ptr_app; + + ptr_app = _app_getappitem (app_hash); if (ptr_app) { @@ -291,7 +293,7 @@ BOOLEAN _app_notifyshow (_In_ HWND hwnd, _In_ PITEM_LOG ptr_log, _In_ BOOLEAN is VOID _app_notifyhide (_In_ HWND hwnd) { - SIZE_T app_hash = _app_notifyget_id (hwnd, FALSE); + ULONG_PTR app_hash = _app_notifyget_id (hwnd, FALSE); PITEM_APP ptr_app = _app_getappitem (app_hash); if (ptr_app) @@ -986,7 +988,7 @@ INT_PTR CALLBACK NotificationProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wp case IDC_RULES_BTN: { ITEM_CONTEXT context = {0}; - SIZE_T app_hash = _app_notifyget_id (hwnd, FALSE); + ULONG_PTR app_hash = _app_notifyget_id (hwnd, FALSE); PITEM_APP ptr_app = _app_getappitem (app_hash); if (ptr_app) @@ -1018,7 +1020,7 @@ INT_PTR CALLBACK NotificationProc (_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wp PITEM_APP ptr_app; PITEM_RULE ptr_rule; PITEM_LOG ptr_log; - SIZE_T app_hash; + ULONG_PTR app_hash; ptr_log = _app_notifyget_obj (_app_notifyget_id (hwnd, FALSE)); diff --git a/src/notifications.h b/src/notifications.h index 9589b39d..eadf7ed4 100644 --- a/src/notifications.h +++ b/src/notifications.h @@ -9,8 +9,8 @@ BOOLEAN _app_notifycommand (_In_ HWND hwnd, _In_ INT button_id, _In_ LONG64 seco BOOLEAN _app_notifyadd (_In_ HWND hwnd, _In_ PITEM_LOG ptr_log, _In_ PITEM_APP ptr_app); VOID _app_freenotify (_Inout_ PITEM_APP ptr_app); -SIZE_T _app_notifyget_id (_In_ HWND hwnd, _In_ BOOLEAN is_nearest); -PITEM_LOG _app_notifyget_obj (_In_ SIZE_T app_hash); +ULONG_PTR _app_notifyget_id (_In_ HWND hwnd, _In_ BOOLEAN is_nearest); +PITEM_LOG _app_notifyget_obj (_In_ ULONG_PTR app_hash); BOOLEAN _app_notifyshow (_In_ HWND hwnd, _In_ PITEM_LOG ptr_log, _In_ BOOLEAN is_forced, _In_ BOOLEAN is_safety); VOID _app_notifyhide (_In_ HWND hwnd); diff --git a/src/profile.c b/src/profile.c index 03e8db6e..333bfd48 100644 --- a/src/profile.c +++ b/src/profile.c @@ -59,7 +59,7 @@ PVOID _app_getappinfo (_In_ PITEM_APP ptr_app, _In_ ENUM_INFO_DATA info_data) } _Ret_maybenull_ -PVOID _app_getappinfobyhash (_In_ SIZE_T app_hash, _In_ ENUM_INFO_DATA info_data) +PVOID _app_getappinfobyhash (_In_ ULONG_PTR app_hash, _In_ ENUM_INFO_DATA info_data) { PITEM_APP ptr_app; @@ -106,7 +106,7 @@ VOID _app_setappinfo (_In_ PITEM_APP ptr_app, _In_ ENUM_INFO_DATA info_data, _In } } -VOID _app_setappinfobyhash (_In_ SIZE_T app_hash, _In_ ENUM_INFO_DATA info_data, _In_ PVOID value) +VOID _app_setappinfobyhash (_In_ ULONG_PTR app_hash, _In_ ENUM_INFO_DATA info_data, _In_ PVOID value) { PITEM_APP ptr_app = _app_getappitem (app_hash); @@ -151,7 +151,7 @@ PITEM_APP _app_addapplication (_In_opt_ HWND hwnd, _In_ ENUM_TYPE_DATA type, _In PITEM_APP ptr_app_added; PR_STRING signature_string; SIZE_T path_length; - SIZE_T app_hash; + ULONG_PTR app_hash; BOOLEAN is_ntoskrnl; path_length = _r_str_length (path); @@ -310,7 +310,7 @@ PITEM_RULE _app_addrule (_In_opt_ PR_STRING name, _In_opt_ PR_STRING rule_remote return ptr_rule; } -PITEM_RULE_CONFIG _app_addruleconfigtable (_In_ PR_HASHTABLE hashtable, _In_ SIZE_T rule_hash, _In_opt_ PR_STRING name, _In_ BOOLEAN is_enabled) +PITEM_RULE_CONFIG _app_addruleconfigtable (_In_ PR_HASHTABLE hashtable, _In_ ULONG_PTR rule_hash, _In_opt_ PR_STRING name, _In_ BOOLEAN is_enabled) { ITEM_RULE_CONFIG entry = {0}; @@ -321,7 +321,7 @@ PITEM_RULE_CONFIG _app_addruleconfigtable (_In_ PR_HASHTABLE hashtable, _In_ SIZ } _Ret_maybenull_ -PITEM_APP _app_getappitem (_In_ SIZE_T app_hash) +PITEM_APP _app_getappitem (_In_ ULONG_PTR app_hash) { PITEM_APP ptr_app; @@ -350,7 +350,7 @@ PITEM_RULE _app_getrulebyid (_In_ SIZE_T index) } _Ret_maybenull_ -PITEM_RULE _app_getrulebyhash (_In_ SIZE_T rule_hash) +PITEM_RULE _app_getrulebyhash (_In_ ULONG_PTR rule_hash) { PITEM_RULE ptr_rule; @@ -383,7 +383,7 @@ PITEM_RULE _app_getrulebyhash (_In_ SIZE_T rule_hash) } _Ret_maybenull_ -PITEM_RULE_CONFIG _app_getruleconfigitem (_In_ SIZE_T rule_hash) +PITEM_RULE_CONFIG _app_getruleconfigitem (_In_ ULONG_PTR rule_hash) { PITEM_RULE_CONFIG ptr_rule_config; @@ -399,9 +399,11 @@ PITEM_RULE_CONFIG _app_getruleconfigitem (_In_ SIZE_T rule_hash) return ptr_rule_config; } -SIZE_T _app_getnetworkapp (_In_ SIZE_T network_hash) +ULONG_PTR _app_getnetworkapp (_In_ ULONG_PTR network_hash) { - PITEM_NETWORK ptr_network = _app_getnetworkitem (network_hash); + PITEM_NETWORK ptr_network; + + ptr_network = _app_getnetworkitem (network_hash); if (ptr_network) return ptr_network->app_hash; @@ -410,7 +412,7 @@ SIZE_T _app_getnetworkapp (_In_ SIZE_T network_hash) } _Ret_maybenull_ -PITEM_NETWORK _app_getnetworkitem (_In_ SIZE_T network_hash) +PITEM_NETWORK _app_getnetworkitem (_In_ ULONG_PTR network_hash) { PITEM_NETWORK ptr_network; @@ -440,13 +442,14 @@ PITEM_LOG _app_getlogitem (_In_ SIZE_T index) return _r_obj_referencesafe (ptr_log); } -SIZE_T _app_getlogapp (_In_ SIZE_T index) +ULONG_PTR _app_getlogapp (_In_ SIZE_T index) { PITEM_LOG ptr_log = _app_getlogitem (index); + ULONG_PTR app_hash; if (ptr_log) { - SIZE_T app_hash = ptr_log->app_hash; + app_hash = ptr_log->app_hash; _r_obj_dereference (ptr_log); @@ -456,7 +459,7 @@ SIZE_T _app_getlogapp (_In_ SIZE_T index) return 0; } -COLORREF _app_getappcolor (_In_ INT listview_id, _In_ SIZE_T app_hash, _In_ BOOLEAN is_systemapp, _In_ BOOLEAN is_validconnection) +COLORREF _app_getappcolor (_In_ INT listview_id, _In_ ULONG_PTR app_hash, _In_ BOOLEAN is_systemapp, _In_ BOOLEAN is_validconnection) { PITEM_APP ptr_app = _app_getappitem (app_hash); LPCWSTR color_value = NULL; @@ -525,7 +528,7 @@ CleanupExit: return 0; } -VOID _app_freeapplication (_In_ SIZE_T app_hash) +VOID _app_freeapplication (_In_ ULONG_PTR app_hash) { PITEM_RULE ptr_rule; @@ -1043,7 +1046,7 @@ VOID _app_setruleiteminfo (_In_ HWND hwnd, _In_ INT listview_id, _In_ INT item_i { PITEM_APP ptr_app; PR_HASHSTORE hashstore; - SIZE_T hash_code; + ULONG_PTR hash_code; SIZE_T enum_key = 0; INT app_listview_id; INT item_pos; @@ -1075,7 +1078,7 @@ VOID _app_ruleenable (_Inout_ PITEM_RULE ptr_rule, _In_ BOOLEAN is_enable, _In_ if (ptr_rule->is_readonly && !_r_obj_isstringempty (ptr_rule->name)) { PITEM_RULE_CONFIG ptr_config; - SIZE_T rule_hash = _r_obj_getstringhash (ptr_rule->name); + ULONG_PTR rule_hash = _r_obj_getstringhash (ptr_rule->name); if (rule_hash) { @@ -1220,7 +1223,7 @@ VOID _app_ruleblocklistset (_In_opt_ HWND hwnd, _In_ INT spy_state, _In_ INT upd } _Ret_maybenull_ -PR_STRING _app_appexpandrules (_In_ SIZE_T app_hash, _In_ LPCWSTR delimeter) +PR_STRING _app_appexpandrules (_In_ ULONG_PTR app_hash, _In_ LPCWSTR delimeter) { R_STRINGBUILDER buffer; PR_STRING string; @@ -1274,7 +1277,7 @@ PR_STRING _app_rulesexpandapps (_In_ PITEM_RULE ptr_rule, _In_ BOOLEAN is_fordis PR_STRING string; PITEM_APP ptr_app; PR_HASHSTORE hashstore; - SIZE_T hash_code; + ULONG_PTR hash_code; SIZE_T enum_key = 0; _r_obj_initializestringbuilder (&buffer); @@ -1366,7 +1369,7 @@ PR_STRING _app_rulesexpandrules (_In_ PR_STRING rule, _In_ LPCWSTR delimeter) return NULL; } -BOOLEAN _app_isappfromsystem (_In_opt_ LPCWSTR path, _In_ SIZE_T app_hash) +BOOLEAN _app_isappfromsystem (_In_opt_ LPCWSTR path, _In_ ULONG_PTR app_hash) { if (app_hash == config.ntoskrnl_hash || app_hash == config.svchost_hash) return TRUE; @@ -1385,7 +1388,7 @@ BOOLEAN _app_isappfromsystem (_In_opt_ LPCWSTR path, _In_ SIZE_T app_hash) return FALSE; } -BOOLEAN _app_isapphaveconnection (_In_ SIZE_T app_hash) +BOOLEAN _app_isapphaveconnection (_In_ ULONG_PTR app_hash) { PITEM_NETWORK ptr_network; SIZE_T enum_key = 0; @@ -1440,7 +1443,7 @@ BOOLEAN _app_isapphavedrive (_In_ INT letter) return FALSE; } -BOOLEAN _app_isapphaverule (_In_ SIZE_T app_hash, _In_ BOOLEAN is_countdisabled) +BOOLEAN _app_isapphaverule (_In_ ULONG_PTR app_hash, _In_ BOOLEAN is_countdisabled) { PITEM_RULE ptr_rule; @@ -1617,7 +1620,7 @@ VOID _app_profile_load_helper (_Inout_ PR_XML_LIBRARY xml_library, _In_ ENUM_TYP ADDRESS_FAMILY af; PITEM_RULE ptr_rule; PITEM_APP ptr_app; - SIZE_T rule_hash; + ULONG_PTR rule_hash; rule_name = _r_xml_getattribute_string (xml_library, L"name"); @@ -1733,7 +1736,7 @@ VOID _app_profile_load_helper (_Inout_ PR_XML_LIBRARY xml_library, _In_ ENUM_TYP _r_str_replacechar (string->buffer, DIVIDER_RULE[0], DIVIDER_APP[0]); // for compat with old profiles R_STRINGREF remaining_part; - SIZE_T app_hash; + ULONG_PTR app_hash; _r_obj_initializestringref2 (&remaining_part, string); @@ -1793,7 +1796,7 @@ VOID _app_profile_load_helper (_Inout_ PR_XML_LIBRARY xml_library, _In_ ENUM_TYP { PR_STRING rule_name; PITEM_RULE_CONFIG ptr_config; - SIZE_T rule_hash; + ULONG_PTR rule_hash; rule_name = _r_xml_getattribute_string (xml_library, L"name"); @@ -1814,10 +1817,13 @@ VOID _app_profile_load_helper (_Inout_ PR_XML_LIBRARY xml_library, _In_ ENUM_TYP _r_spinlock_releaseexclusive (&lock_rules_config); - ptr_config->apps = _r_xml_getattribute_string (xml_library, L"apps"); + if (ptr_config) + { + ptr_config->apps = _r_xml_getattribute_string (xml_library, L"apps"); - if (ptr_config->apps && version < XML_PROFILE_VER_3) - _r_str_replacechar (ptr_config->apps->buffer, DIVIDER_RULE[0], DIVIDER_APP[0]); // for compat with old profiles + if (ptr_config->apps && version < XML_PROFILE_VER_3) + _r_str_replacechar (ptr_config->apps->buffer, DIVIDER_RULE[0], DIVIDER_APP[0]); // for compat with old profiles + } } } @@ -2282,7 +2288,7 @@ VOID _app_profile_save () continue; BOOLEAN is_enabled_default = ptr_config->is_enabled; - SIZE_T rule_hash = _r_obj_getstringhash (ptr_config->name); + ULONG_PTR rule_hash = _r_obj_getstringhash (ptr_config->name); ptr_rule = _app_getrulebyhash (rule_hash); if (ptr_rule) diff --git a/src/profile.h b/src/profile.h index b5f73a73..badcf651 100644 --- a/src/profile.h +++ b/src/profile.h @@ -7,10 +7,10 @@ _Ret_maybenull_ PVOID _app_getappinfo (_In_ PITEM_APP ptr_app, _In_ ENUM_INFO_DATA info_data); _Ret_maybenull_ -PVOID _app_getappinfobyhash (_In_ SIZE_T app_hash, _In_ ENUM_INFO_DATA info_data); +PVOID _app_getappinfobyhash (_In_ ULONG_PTR app_hash, _In_ ENUM_INFO_DATA info_data); VOID _app_setappinfo (_In_ PITEM_APP ptr_app, _In_ ENUM_INFO_DATA info_data, _In_ PVOID value); -VOID _app_setappinfobyhash (_In_ SIZE_T app_hash, _In_ ENUM_INFO_DATA info_data, _In_ PVOID value); +VOID _app_setappinfobyhash (_In_ ULONG_PTR app_hash, _In_ ENUM_INFO_DATA info_data, _In_ PVOID value); _Ret_maybenull_ PVOID _app_getruleinfo (_In_ PITEM_RULE ptr_rule, _In_ ENUM_INFO_DATA info_data); @@ -22,37 +22,37 @@ _Ret_maybenull_ PITEM_APP _app_addapplication (_In_opt_ HWND hwnd, _In_ ENUM_TYPE_DATA type, _In_ LPCWSTR path, _In_opt_ PR_STRING display_name, _In_opt_ PR_STRING real_path); PITEM_RULE _app_addrule (_In_opt_ PR_STRING name, _In_opt_ PR_STRING rule_remote, _In_opt_ PR_STRING rule_local, _In_ FWP_DIRECTION direction, _In_ UINT8 protocol, _In_ ADDRESS_FAMILY af); -PITEM_RULE_CONFIG _app_addruleconfigtable (_In_ PR_HASHTABLE hashtable, _In_ SIZE_T rule_hash, _In_opt_ PR_STRING name, _In_ BOOLEAN is_enabled); +PITEM_RULE_CONFIG _app_addruleconfigtable (_In_ PR_HASHTABLE hashtable, _In_ ULONG_PTR rule_hash, _In_opt_ PR_STRING name, _In_ BOOLEAN is_enabled); _Ret_maybenull_ -PITEM_APP _app_getappitem (_In_ SIZE_T app_hash); +PITEM_APP _app_getappitem (_In_ ULONG_PTR app_hash); _Ret_maybenull_ PITEM_RULE _app_getrulebyid (_In_ SIZE_T index); _Ret_maybenull_ -PITEM_RULE _app_getrulebyhash (_In_ SIZE_T rule_hash); +PITEM_RULE _app_getrulebyhash (_In_ ULONG_PTR rule_hash); _Ret_maybenull_ -PITEM_RULE_CONFIG _app_getruleconfigitem (_In_ SIZE_T rule_hash); +PITEM_RULE_CONFIG _app_getruleconfigitem (_In_ ULONG_PTR rule_hash); -SIZE_T _app_getnetworkapp (_In_ SIZE_T network_hash); +ULONG_PTR _app_getnetworkapp (_In_ ULONG_PTR network_hash); _Ret_maybenull_ -PITEM_NETWORK _app_getnetworkitem (_In_ SIZE_T network_hash); +PITEM_NETWORK _app_getnetworkitem (_In_ ULONG_PTR network_hash); _Ret_maybenull_ PITEM_LOG _app_getlogitem (_In_ SIZE_T index); -SIZE_T _app_getlogapp (_In_ SIZE_T index); -COLORREF _app_getappcolor (_In_ INT listview_id, _In_ SIZE_T app_hash, _In_ BOOLEAN is_systemapp, _In_ BOOLEAN is_validconnection); +ULONG_PTR _app_getlogapp (_In_ SIZE_T index); +COLORREF _app_getappcolor (_In_ INT listview_id, _In_ ULONG_PTR app_hash, _In_ BOOLEAN is_systemapp, _In_ BOOLEAN is_validconnection); -VOID _app_freeapplication (_In_ SIZE_T app_hash); +VOID _app_freeapplication (_In_ ULONG_PTR app_hash); -BOOLEAN _app_isappfromsystem (_In_opt_ LPCWSTR path, _In_ SIZE_T app_hash); -BOOLEAN _app_isapphaveconnection (_In_ SIZE_T app_hash); +BOOLEAN _app_isappfromsystem (_In_opt_ LPCWSTR path, _In_ ULONG_PTR app_hash); +BOOLEAN _app_isapphaveconnection (_In_ ULONG_PTR app_hash); BOOLEAN _app_isapphavedrive (_In_ INT letter); -BOOLEAN _app_isapphaverule (_In_ SIZE_T app_hash, _In_ BOOLEAN is_countdisabled); +BOOLEAN _app_isapphaverule (_In_ ULONG_PTR app_hash, _In_ BOOLEAN is_countdisabled); BOOLEAN _app_isappexists (_In_ PITEM_APP ptr_app); FORCEINLINE BOOLEAN _app_isappused (_In_ PITEM_APP ptr_app) @@ -119,7 +119,7 @@ BOOLEAN _app_ruleblocklistsetstate (_Inout_ PITEM_RULE ptr_rule, _In_ INT spy_st VOID _app_ruleblocklistset (_In_opt_ HWND hwnd, _In_ INT spy_state, _In_ INT update_state, _In_ INT extra_state, _In_ BOOLEAN is_instantapply); _Ret_maybenull_ -PR_STRING _app_appexpandrules (_In_ SIZE_T app_hash, _In_ LPCWSTR delimeter); +PR_STRING _app_appexpandrules (_In_ ULONG_PTR app_hash, _In_ LPCWSTR delimeter); _Ret_maybenull_ PR_STRING _app_rulesexpandapps (_In_ PITEM_RULE ptr_rule, _In_ BOOLEAN is_fordisplay, _In_ LPCWSTR delimeter); diff --git a/src/timer.c b/src/timer.c index 14b88389..e26299d9 100644 --- a/src/timer.c +++ b/src/timer.c @@ -152,7 +152,7 @@ VOID CALLBACK _app_timer_callback (_Inout_ PTP_CALLBACK_INSTANCE instance, _Inou PR_LIST rules; INT listview_id; - ptr_app = _app_getappitem ((SIZE_T)context); + ptr_app = _app_getappitem ((ULONG_PTR)context); if (!ptr_app) return; diff --git a/src/wfp.c b/src/wfp.c index 6dd56f6e..41cfead8 100644 --- a/src/wfp.c +++ b/src/wfp.c @@ -782,7 +782,7 @@ BOOLEAN _wfp_destroyfilters_array (_In_ HANDLE hengine, _In_ PR_ARRAY guids, _In return TRUE; } -BOOLEAN _wfp_createrulefilter (_In_ HANDLE hengine, _In_ ENUM_TYPE_DATA filter_type, _In_opt_ LPCWSTR name, _In_opt_ SIZE_T app_hash, _In_opt_ PR_STRING rule_remote, _In_opt_ PR_STRING rule_local, _In_opt_ UINT8 protocol, _In_opt_ ADDRESS_FAMILY af, _In_opt_ FWP_DIRECTION dir, _In_ UINT8 weight, _In_ FWP_ACTION_TYPE action, _In_opt_ UINT32 flag, _In_opt_ PR_ARRAY guids) +BOOLEAN _wfp_createrulefilter (_In_ HANDLE hengine, _In_ ENUM_TYPE_DATA filter_type, _In_opt_ LPCWSTR name, _In_opt_ ULONG_PTR app_hash, _In_opt_ PR_STRING rule_remote, _In_opt_ PR_STRING rule_local, _In_opt_ UINT8 protocol, _In_opt_ ADDRESS_FAMILY af, _In_opt_ FWP_DIRECTION dir, _In_ UINT8 weight, _In_ FWP_ACTION_TYPE action, _In_opt_ UINT32 flag, _In_opt_ PR_ARRAY guids) { UINT32 count = 0; FWPM_FILTER_CONDITION fwfc[8] = {0}; @@ -802,7 +802,7 @@ BOOLEAN _wfp_createrulefilter (_In_ HANDLE hengine, _In_ ENUM_TYPE_DATA filter_t if (!ptr_app) { - _r_log_v (LOG_LEVEL_ERROR, 0, TEXT (__FUNCTION__), 0, L"App \"%" PR_SIZE_T L"\" not found!", app_hash); + _r_log_v (LOG_LEVEL_ERROR, 0, TEXT (__FUNCTION__), 0, L"App \"%" PR_ULONG_PTR L"\" not found!", app_hash); goto CleanupExit; } @@ -1177,7 +1177,7 @@ BOOLEAN _wfp_create4filters (_In_ HANDLE hengine, _In_ PR_LIST rules, _In_ UINT if (!_r_obj_ishashtableempty (ptr_rule->apps)) { PR_HASHSTORE hashstore; - SIZE_T hash_code; + ULONG_PTR hash_code; SIZE_T enum_key = 0; while (_r_obj_enumhashtable (ptr_rule->apps, &hashstore, &hash_code, &enum_key)) diff --git a/src/wfp.h b/src/wfp.h index ee56d637..69c81980 100644 --- a/src/wfp.h +++ b/src/wfp.h @@ -26,7 +26,7 @@ VOID _wfp_clearfilter_ids (); VOID _wfp_destroyfilters (_In_ HANDLE hengine); BOOLEAN _wfp_destroyfilters_array (_In_ HANDLE hengine, _In_ PR_ARRAY guids, _In_ UINT line); -BOOLEAN _wfp_createrulefilter (_In_ HANDLE hengine, _In_ ENUM_TYPE_DATA filter_type, _In_opt_ LPCWSTR name, _In_opt_ SIZE_T app_hash, _In_opt_ PR_STRING rule_remote, _In_opt_ PR_STRING rule_local, _In_opt_ UINT8 protocol, _In_opt_ ADDRESS_FAMILY af, _In_opt_ FWP_DIRECTION dir, _In_ UINT8 weight, _In_ FWP_ACTION_TYPE action, _In_opt_ UINT32 flag, _In_opt_ PR_ARRAY guids); +BOOLEAN _wfp_createrulefilter (_In_ HANDLE hengine, _In_ ENUM_TYPE_DATA filter_type, _In_opt_ LPCWSTR name, _In_opt_ ULONG_PTR app_hash, _In_opt_ PR_STRING rule_remote, _In_opt_ PR_STRING rule_local, _In_opt_ UINT8 protocol, _In_opt_ ADDRESS_FAMILY af, _In_opt_ FWP_DIRECTION dir, _In_ UINT8 weight, _In_ FWP_ACTION_TYPE action, _In_opt_ UINT32 flag, _In_opt_ PR_ARRAY guids); BOOLEAN _wfp_create4filters (_In_ HANDLE hengine, _In_ PR_LIST rules, _In_ UINT line, _In_ BOOLEAN is_intransact); BOOLEAN _wfp_create3filters (_In_ HANDLE hengine, _In_ PR_LIST rules, _In_ UINT line, _In_ BOOLEAN is_intransact);