FwpmSubLayerAdd0 function

The FwpmSubLayerAdd0 function adds a new sublayer to the system.

Syntax


DWORD WINAPI FwpmSubLayerAdd0(
  _In_           HANDLE               engineHandle,
  _In_     const FWPM_SUBLAYER0       *subLayer,
  _In_opt_       PSECURITY_DESCRIPTOR sd
);

Parameters

engineHandle [in]

Type: HANDLE

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

subLayer [in]

Type: const FWPM_SUBLAYER0*

The sublayer to be added.

sd [in, optional]

Type: PSECURITY_DESCRIPTOR

Security information for the sublayer object.

Return value

Type: DWORD

Return code/valueDescription
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;
}


Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Fwpmu.h

Library

Fwpuclnt.lib

DLL

Fwpuclnt.dll

See also

FWPM_SUBLAYER0
WFP Functions
Management Functions

 

 

Show: