Skip to content

Commit bd3a570

Browse files
committed
upd project sdk
1 parent 80fa523 commit bd3a570

File tree

4 files changed

+67
-69
lines changed

4 files changed

+67
-69
lines changed

src/controls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ PR_STRING _app_gettooltipbylparam (
336336

337337
_r_obj_appendstringbuilderformat (
338338
&sb,
339-
L"%s (#%" TEXT (PR_ULONG_PTR) L")\r\n%s (%s):\r\n%s%s\r\n%s (%s):\r\n%s%s",
339+
L"%s (#%" TEXT (PR_LONG_PTR) L")\r\n%s (%s):\r\n%s%s\r\n%s (%s):\r\n%s%s",
340340
_r_obj_getstringordefault (ptr_rule->name, _r_locale_getstring (IDS_STATUS_EMPTY)),
341341
lparam,
342342
_r_locale_getstring (IDS_RULE),
@@ -661,7 +661,7 @@ VOID _app_setinterfacestate (
661661

662662
_r_wnd_seticon (hwnd, hico_sm, hico_big);
663663

664-
//_r_wnd_sendmessage (hwnd, IDC_STATUSBAR, SB_SETICON, 0, (LPARAM)hico_sm);
664+
//_r_status_seticon (hwnd, IDC_STATUSBAR, 0, hico_sm);
665665

666666
if (!_wfp_isfiltersapplying ())
667667
_r_status_settext (hwnd, IDC_STATUSBAR, 0, _app_getstatelocale (install_type));

src/security.c

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ PACL _app_createaccesscontrollist (
123123

124124
status = SetEntriesInAclW (count, ea, acl, &new_dacl);
125125

126-
if (status == ERROR_SUCCESS)
127-
return new_dacl;
126+
if (status != ERROR_SUCCESS)
127+
_r_log (LOG_LEVEL_ERROR, NULL, L"SetEntriesInAclW", status, NULL);
128128

129-
_r_log (LOG_LEVEL_ERROR, NULL, L"SetEntriesInAclW", status, NULL);
129+
return new_dacl;
130130
}
131131

132132
return NULL;
@@ -437,7 +437,7 @@ VOID _app_setprovidersecurity (
437437
hengine,
438438
provider_guid,
439439
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
440-
(const PSID)config.builtin_admins_sid,
440+
(PCSID)config.builtin_admins_sid,
441441
NULL,
442442
new_dacl,
443443
NULL
@@ -496,7 +496,7 @@ VOID _app_setsublayersecurity (
496496
hengine,
497497
sublayer_guid,
498498
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
499-
(const PSID)config.builtin_admins_sid,
499+
(PCSID)config.builtin_admins_sid,
500500
NULL,
501501
new_dacl,
502502
NULL
@@ -556,7 +556,7 @@ VOID _app_setcalloutsecurity (
556556
hengine,
557557
callout_guid,
558558
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
559-
(const PSID)config.builtin_admins_sid,
559+
(PCSID)config.builtin_admins_sid,
560560
NULL,
561561
new_dacl,
562562
NULL
@@ -578,7 +578,7 @@ VOID _app_setfiltersecurity (
578578
_In_ LPCGUID filter_guid,
579579
_In_ BOOLEAN is_secure,
580580
_In_ LPCWSTR file_name,
581-
_In_ UINT line
581+
_In_ ULONG line
582582
)
583583
{
584584
PSECURITY_DESCRIPTOR security_descriptor;
@@ -589,47 +589,30 @@ VOID _app_setfiltersecurity (
589589
PACL new_dacl;
590590
ULONG status;
591591

592-
status = FwpmFilterGetSecurityInfoByKey0 (
593-
hengine,
594-
filter_guid,
595-
DACL_SECURITY_INFORMATION,
596-
&sid_owner,
597-
&sid_group,
598-
&dacl,
599-
&sacl,
600-
&security_descriptor
601-
);
592+
status = FwpmFilterGetSecurityInfoByKey0 (hengine, filter_guid, DACL_SECURITY_INFORMATION, &sid_owner, &sid_group, &dacl, &sacl, &security_descriptor);
602593

603-
if (status != ERROR_SUCCESS)
594+
if (status == ERROR_SUCCESS)
604595
{
605-
// FWP_E_FILTER_NOT_FOUND
606-
_r_log_v (LOG_LEVEL_ERROR, NULL, L"FwpmFilterGetSecurityInfoByKey0", status, L"%s:%" TEXT (PRIu32), DBG_ARG_VAR);
607-
608-
return;
609-
}
610-
611-
if (dacl)
612-
{
613-
new_dacl = _app_createaccesscontrollist (dacl, is_secure);
614-
615-
if (new_dacl)
596+
if (dacl)
616597
{
617-
status = FwpmFilterSetSecurityInfoByKey0 (
618-
hengine,
619-
filter_guid,
620-
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
621-
(const PSID)config.builtin_admins_sid,
622-
NULL,
623-
new_dacl,
624-
NULL
625-
);
598+
new_dacl = _app_createaccesscontrollist (dacl, is_secure);
626599

627-
if (status != ERROR_SUCCESS)
628-
_r_log_v (LOG_LEVEL_ERROR, NULL, L"FwpmFilterSetSecurityInfoByKey0", status, L"#%" TEXT (PRIu32), line);
600+
if (new_dacl)
601+
{
602+
status = FwpmFilterSetSecurityInfoByKey0 (hengine, filter_guid, OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, (PCSID)config.builtin_admins_sid, NULL, new_dacl, NULL);
629603

630-
LocalFree (new_dacl);
604+
if (status != ERROR_SUCCESS)
605+
_r_log_v (LOG_LEVEL_ERROR, NULL, L"FwpmFilterSetSecurityInfoByKey0", status, L"#%d", line);
606+
607+
LocalFree (new_dacl);
608+
}
631609
}
632610
}
611+
else
612+
{
613+
//if (status != FWP_E_FILTER_NOT_FOUND)
614+
_r_log_v (LOG_LEVEL_ERROR, NULL, L"FwpmFilterGetSecurityInfoByKey0", status, L"%s:%d", DBG_ARG_VAR);
615+
}
633616

634617
if (security_descriptor)
635618
FwpmFreeMemory0 ((PVOID_PTR)&security_descriptor);

src/security.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ VOID _app_setfiltersecurity (
5151
_In_ LPCGUID filter_guid,
5252
_In_ BOOLEAN is_secure,
5353
_In_ LPCWSTR file_name,
54-
_In_ UINT line
54+
_In_ ULONG line
5555
);

src/wfp.c

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ VOID _wfp_uninitialize (
449449
{
450450
guid = _r_obj_getarrayitem (callouts, i);
451451

452-
_app_setcalloutsecurity (engine_handle, guid, FALSE);
452+
if (guid)
453+
_app_setcalloutsecurity (engine_handle, guid, FALSE);
453454
}
454455
}
455456

@@ -462,6 +463,9 @@ VOID _wfp_uninitialize (
462463
{
463464
guid = _r_obj_getarrayitem (callouts, i);
464465

466+
if (!guid)
467+
continue;
468+
465469
status = FwpmCalloutDeleteByKey0 (engine_handle, guid);
466470

467471
if (status != ERROR_SUCCESS)
@@ -508,7 +512,7 @@ VOID _wfp_installfilters (
508512
LPGUID guid;
509513
PITEM_APP ptr_app = NULL;
510514
PITEM_RULE ptr_rule;
511-
ULONG_PTR enum_key;
515+
ULONG_PTR enum_key = 0;
512516
BOOLEAN is_intransact;
513517
ULONG status;
514518

@@ -529,7 +533,8 @@ VOID _wfp_installfilters (
529533
{
530534
guid = _r_obj_getarrayitem (guids, i);
531535

532-
_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG);
536+
if (guid)
537+
_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG);
533538
}
534539
}
535540

@@ -542,7 +547,8 @@ VOID _wfp_installfilters (
542547
{
543548
guid = _r_obj_getarrayitem (guids, i);
544549

545-
_wfp_deletefilter (engine_handle, guid);
550+
if (guid)
551+
_wfp_deletefilter (engine_handle, guid);
546552
}
547553

548554
_r_obj_dereference (guids);
@@ -551,8 +557,6 @@ VOID _wfp_installfilters (
551557
rules = _r_obj_createlist (10, &_r_obj_dereference);
552558

553559
// apply apps rules
554-
enum_key = 0;
555-
556560
_r_queuedlock_acquireshared (&lock_apps);
557561

558562
while (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))
@@ -608,7 +612,8 @@ VOID _wfp_installfilters (
608612
{
609613
guid = _r_obj_getarrayitem (guids, i);
610614

611-
_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG);
615+
if (guid)
616+
_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG);
612617
}
613618

614619
_r_obj_dereference (guids);
@@ -637,7 +642,7 @@ BOOLEAN _wfp_transact_start (
637642

638643
if (status != ERROR_SUCCESS)
639644
{
640-
_r_log_v (LOG_LEVEL_ERROR, &GUID_TrayIcon, L"FwpmTransactionBegin0", status, L"%s:%" TEXT (PR_ULONG), DBG_ARG_VAR);
645+
_r_log_v (LOG_LEVEL_ERROR, &GUID_TrayIcon, L"FwpmTransactionBegin0", status, L"%s:%d", DBG_ARG_VAR);
641646

642647
return FALSE;
643648
}
@@ -659,7 +664,7 @@ BOOLEAN _wfp_transact_commit (
659664
{
660665
FwpmTransactionAbort0 (engine_handle);
661666

662-
_r_log_v (LOG_LEVEL_ERROR, &GUID_TrayIcon, L"FwpmTransactionCommit0", status, L"%s:%" TEXT (PR_ULONG), DBG_ARG_VAR);
667+
_r_log_v (LOG_LEVEL_ERROR, &GUID_TrayIcon, L"FwpmTransactionCommit0", status, L"%s:%d", DBG_ARG_VAR);
663668

664669
return FALSE;
665670
}
@@ -867,21 +872,20 @@ VOID _wfp_clearfilter_ids ()
867872
{
868873
PITEM_APP ptr_app = NULL;
869874
PITEM_RULE ptr_rule;
870-
ULONG_PTR enum_key;
875+
ULONG_PTR enum_key = 0;
871876

872877
// clear common filters
873878
_r_obj_cleararray (filter_ids);
874879

875880
// clear apps filters
876881
_r_queuedlock_acquireshared (&lock_apps);
877882

878-
enum_key = 0;
879-
880883
while (_r_obj_enumhashtablepointer (apps_table, (PVOID_PTR)&ptr_app, NULL, &enum_key))
881884
{
882885
ptr_app->is_haveerrors = FALSE;
883886

884-
_r_obj_cleararray (ptr_app->guids);
887+
if (ptr_app->guids)
888+
_r_obj_cleararray (ptr_app->guids);
885889
}
886890

887891
_r_queuedlock_releaseshared (&lock_apps);
@@ -947,7 +951,8 @@ VOID _wfp_destroyfilters_array (
947951
{
948952
guid = _r_obj_getarrayitem (guids, i);
949953

950-
_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);
954+
if (guid)
955+
_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);
951956
}
952957

953958
is_intransact = _wfp_transact_start (engine_handle, DBG_ARG_VAR);
@@ -956,7 +961,8 @@ VOID _wfp_destroyfilters_array (
956961
{
957962
guid = _r_obj_getarrayitem (guids, i);
958963

959-
_wfp_deletefilter (engine_handle, guid);
964+
if (guid)
965+
_wfp_deletefilter (engine_handle, guid);
960966
}
961967

962968
if (is_intransact)
@@ -1426,7 +1432,8 @@ BOOLEAN _wfp_create4filters (
14261432
{
14271433
guid = _r_obj_getarrayitem (guids, i);
14281434

1429-
_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);
1435+
if (guid)
1436+
_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);
14301437
}
14311438

14321439
_r_queuedlock_acquireshared (&lock_transaction);
@@ -1438,7 +1445,8 @@ BOOLEAN _wfp_create4filters (
14381445
{
14391446
guid = _r_obj_getarrayitem (guids, i);
14401447

1441-
_wfp_deletefilter (engine_handle, guid);
1448+
if (guid)
1449+
_wfp_deletefilter (engine_handle, guid);
14421450
}
14431451

14441452
for (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules); i++)
@@ -1585,7 +1593,8 @@ BOOLEAN _wfp_create4filters (
15851593
{
15861594
guid = _r_obj_getarrayitem (ptr_rule->guids, j);
15871595

1588-
_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG_VAR);
1596+
if (guid)
1597+
_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG_VAR);
15891598
}
15901599
}
15911600
}
@@ -1643,7 +1652,8 @@ BOOLEAN _wfp_create3filters (
16431652
{
16441653
guid = _r_obj_getarrayitem (guids, i);
16451654

1646-
_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);
1655+
if (guid)
1656+
_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);
16471657
}
16481658

16491659
_r_queuedlock_acquireshared (&lock_transaction);
@@ -1655,7 +1665,8 @@ BOOLEAN _wfp_create3filters (
16551665
{
16561666
guid = _r_obj_getarrayitem (guids, i);
16571667

1658-
_wfp_deletefilter (engine_handle, guid);
1668+
if (guid)
1669+
_wfp_deletefilter (engine_handle, guid);
16591670
}
16601671

16611672
for (ULONG_PTR i = 0; i < _r_obj_getlistsize (rules); i++)
@@ -1701,7 +1712,8 @@ BOOLEAN _wfp_create3filters (
17011712
{
17021713
guid = _r_obj_getarrayitem (ptr_app->guids, j);
17031714

1704-
_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG_VAR);
1715+
if (guid)
1716+
_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG_VAR);
17051717
}
17061718
}
17071719
}
@@ -1776,7 +1788,8 @@ BOOLEAN _wfp_create2filters (
17761788
{
17771789
guid = _r_obj_getarrayitem (filter_ids, i);
17781790

1779-
_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);
1791+
if (guid)
1792+
_app_setfiltersecurity (engine_handle, guid, FALSE, DBG_ARG_VAR);
17801793
}
17811794
}
17821795

@@ -1791,7 +1804,8 @@ BOOLEAN _wfp_create2filters (
17911804
{
17921805
guid = _r_obj_getarrayitem (filter_ids, i);
17931806

1794-
_wfp_deletefilter (engine_handle, guid);
1807+
if (guid)
1808+
_wfp_deletefilter (engine_handle, guid);
17951809
}
17961810

17971811
_r_obj_cleararray (filter_ids);
@@ -2495,7 +2509,8 @@ BOOLEAN _wfp_create2filters (
24952509
{
24962510
guid = _r_obj_getarrayitem (filter_ids, i);
24972511

2498-
_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG_VAR);
2512+
if (guid)
2513+
_app_setfiltersecurity (engine_handle, guid, TRUE, DBG_ARG_VAR);
24992514
}
25002515

25012516
_r_queuedlock_releaseshared (&lock_transaction);
@@ -2584,8 +2599,8 @@ ULONG _wfp_dumpfilters (
25842599
FWPM_FILTER0 *filter;
25852600
PR_ARRAY guids = NULL;
25862601
HANDLE enum_handle = NULL;
2587-
ULONG status;
25882602
UINT32 return_count;
2603+
ULONG status;
25892604

25902605
*out_buffer = NULL;
25912606

0 commit comments

Comments
 (0)