locked
FwpmFilterAdd0 failed. return value: -2144206841 RRS feed

  • Question

  • Hi, I'm new to WFP

    according to MSDN, after installing the provider, after calling FwpmEngineOpen0()

    one must be able to block all incoming connections, using FwpmFilterAdd0()

    now I used the code in msdn:

    FWPM_FILTER0      fwpFilter;
    FWPM_SUBLAYER0    fwpFilterSubLayer;  
    RtlZeroMemory(&fwpFilter, sizeof(FWPM_FILTER0));
    fwpFilter.layerKey = FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4;
    fwpFilter.action.type = FWP_ACTION_BLOCK;
    if (&fwpFilterSubLayer.subLayerKey != NULL)
    fwpFilter.subLayerKey = fwpFilterSubLayer.subLayerKey;
    fwpFilter.weight.type = FWP_EMPTY; // auto-weight.
    fwpFilter.numFilterConditions = 0; // this applies to all application traffic
    fwpFilter.displayData.name = L"Receive/Accept Layer Block";
    fwpFilter.displayData.description = L"Filter to block all inbound connections.";
    printf("Adding filter to block all inbound connections.\n");
    result = FwpmFilterAdd0(engineHandle, &fwpFilter, NULL, NULL);
    if (result != ERROR_SUCCESS)
        printf("FwpmFilterAdd0 failed. Return value: %d.\n", result);
    else
        printf("Filter added successfully.\n");

    I can't find any clue to how to solve this problem, I don't even understand what the problem is just the ourput says "FwpmFilterAdd0 failed. return value: -2144206841 "

    Im using visual studio 2013 and I'm on my way to develop a simple firewall. please help

    Sunday, November 10, 2013 6:02 PM

Answers

  • Convert the error to hex, and its 80320007. This is fwp_e_sublayer_not_found.  You need to add the sublayer before you can add another object that references it.

    Hope this helps,


    Dusty Harper [MSFT]
    Microsoft Corporation
    ------------------------------------------------------------
    This posting is provided "AS IS", with NO warranties and confers NO rights
    ------------------------------------------------------------


    Sunday, November 10, 2013 11:10 PM
    Moderator

All replies

  • Convert the error to hex, and its 80320007. This is fwp_e_sublayer_not_found.  You need to add the sublayer before you can add another object that references it.

    Hope this helps,


    Dusty Harper [MSFT]
    Microsoft Corporation
    ------------------------------------------------------------
    This posting is provided "AS IS", with NO warranties and confers NO rights
    ------------------------------------------------------------


    Sunday, November 10, 2013 11:10 PM
    Moderator
  • Thank you Dusty

    --

    Monday, November 11, 2013 8:44 PM