0

使用 Windows 过滤平台我需要阻止所有计算机应用程序减去 1 个特定应用程序?

尝试了此代码但不起作用,它会阻止所有流量:(

fwpFilter.layerKey = FWPM_LAYER_ALE_AUTH_CONNECT_V4;
fwpFilter.action.type = FWP_ACTION_BLOCK;
fwpFilter.subLayerKey = subLayerKey;
fwpFilter.weight.type = FWP_EMPTY; 
fwpFilter.numFilterConditions = 0; 
fwpFilter.displayData.name = GetWC("Block All APPS MINUS FIREFOX");
fwpFilter.displayData.description = GetWC("Block All APPS MINUS FIREFOX");

result = FwpmFilterAdd0(engine, &fwpFilter, NULL, NULL);

FWPM_FILTER_CONDITION0 Condition;
fwpFilter.layerKey = FWPM_LAYER_ALE_AUTH_CONNECT_V4;
fwpFilter.action.type = FWP_ACTION_PERMIT;
fwpFilter.weight.type = FWP_EMPTY;
fwpFilter.filterCondition = &Condition;
fwpFilter.numFilterConditions = 1;

PCWSTR appPath = (PCWSTR)GetWC("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
FWP_BYTE_BLOB *fwpApplicationByteBlob;
fwpApplicationByteBlob = (FWP_BYTE_BLOB*)malloc(sizeof(FWP_BYTE_BLOB));
FwpmGetAppIdFromFileName0(appPath, &fwpApplicationByteBlob);

Condition.fieldKey = FWPM_CONDITION_ALE_APP_ID;
Condition.matchType = FWP_MATCH_EQUAL;
Condition.conditionValue.type = FWP_BYTE_BLOB_TYPE;
Condition.conditionValue.byteBlob = fwpApplicationByteBlob;

result = FwpmFilterAdd0(engine, &fwpFilter, NULL, NULL);

提前致谢

4

0 回答 0