Skip to content

Latest commit

 

History

History
209 lines (158 loc) · 5.29 KB

nf-fwpmu-fwpmsublayeradd0.md

File metadata and controls

209 lines (158 loc) · 5.29 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:fwpmu.FwpmSubLayerAdd0
FwpmSubLayerAdd0 function (fwpmu.h)
Adds a new sublayer to the system.
FwpmSubLayerAdd0
FwpmSubLayerAdd0 function [Filtering]
fwp.fwpmsublayeradd0_func
fwpmu/FwpmSubLayerAdd0
fwp\fwpmsublayeradd0_func.htm
fwp
85a6f4a9-297f-491d-b2f7-38de21dbe06c
12/05/2018
FwpmSubLayerAdd0, FwpmSubLayerAdd0 function [Filtering], fwp.fwpmsublayeradd0_func, fwpmu/FwpmSubLayerAdd0
fwpmu.h
Windows
Windows Vista [desktop apps only]
Windows Server 2008 [desktop apps only]
Fwpuclnt.lib
Fwpuclnt.dll
Windows
19H1
FwpmSubLayerAdd0
fwpmu/FwpmSubLayerAdd0
c++
APIRef
kbSyntax
DllExport
Fwpuclnt.dll
FwpmSubLayerAdd0

FwpmSubLayerAdd0 function

-description

The FwpmSubLayerAdd0 function adds a new sublayer to the system.

-parameters

-param engineHandle [in]

Type: HANDLE

Handle for an open session to the filter engine. Call FwpmEngineOpen0 to open a session to the filter engine.

-param subLayer [in]

Type: FWPM_SUBLAYER0*

The sublayer to be added.

-param sd [in, optional]

Type: PSECURITY_DESCRIPTOR

Security information for the sublayer object.

-returns

Type: DWORD

Return code/value Description
ERROR_SUCCESS
0
The sublayer was successfully added.
FWP_E_* error code
0x80320001—0x80320039
A Windows Filtering Platform (WFP) specific error. See WFP Error Codes for details.
RPC_* error code
0x80010001—0x80010122
Failure to communicate with the remote or local firewall engine.

-remarks

If the caller supplies a null security descriptor, the system will assign a default security descriptor.

This function cannot be called from within a read-only transaction. It will fail with FWP_E_INCOMPATIBLE_TXN. See Object Management for more information about transactions.

The caller needs FWPM_ACTRL_ADD access to the sublayers's container and FWPM_ACTRL_ADD_LINK access to the provider (if any). See Access Control for more information.

FwpmSubLayerAdd0 is a specific implementation of FwpmSubLayerAdd. See WFP Version-Independent Names and Targeting Specific Versions of Windows for more information.

Examples

The following C++ example illustrates initialization of a sublayer object and adding the sublayer key to a filter object.

#include <windows.h>
#include <fwpmu.h>
#include <rpc.h>
#include <stdio.h>

#pragma comment(lib, "Fwpuclnt.lib")
#pragma comment(lib, "Rpcrt4.lib")

void main()
{
    FWPM_FILTER0    fwpFilter;
    FWPM_SUBLAYER0    fwpFilterSubLayer;
    HANDLE engineHandle = NULL;     
    DWORD  result = ERROR_SUCCESS; 
    RPC_STATUS rpcStatus = RPC_S_OK;
     
    memset(&fwpFilterSubLayer, 0, sizeof(fwpFilterSubLayer));
    rpcStatus = UuidCreate(&fwpFilterSubLayer.subLayerKey);
          
    if (RPC_S_OK != rpcStatus)
    {
           printf("UuidCreate failed (%d).\n", rpcStatus);
           return;
    }

    result = FwpmEngineOpen0( NULL, RPC_C_AUTHN_WINNT, NULL, NULL, &engineHandle );
    if (result != ERROR_SUCCESS)
    {
        printf("FwpmEngineOpen0 failed.\n");
        return;
    }

    fwpFilterSubLayer.displayData.name = L"MyFilterSublayer";
    fwpFilterSubLayer.displayData.description = L"My filter sublayer";
    fwpFilterSubLayer.flags = 0;
    fwpFilterSubLayer.weight = 0x100;
            
    printf("Adding filter sublayer.\n");
      result = FwpmSubLayerAdd0(engineHandle, &fwpFilterSubLayer, NULL);

      if (result != ERROR_SUCCESS)
      {           
           printf("FwpmSubLayerAdd0 failed (%d).\n", result);
           return;
    }

    // Add sublayer key to a filter.
    memset(&fwpFilter, 0, sizeof(FWPM_FILTER0));

    if (&fwpFilterSubLayer.subLayerKey != NULL)
        fwpFilter.subLayerKey = fwpFilterSubLayer.subLayerKey;

    // Finish initializing filter...

    return;
}

-see-also

FWPM_SUBLAYER0

Management Functions

WFP Functions