Win32 API 日本語リファレンス
ホームNetworkManagement.IpHelper › PfAddFiltersToInterface

PfAddFiltersToInterface

関数
インターフェイスに送受信パケットフィルタを追加する。
DLLIPHLPAPI.dll呼出規約winapi

シグネチャ

// IPHLPAPI.dll
#include <windows.h>

DWORD PfAddFiltersToInterface(
    void* ih,
    DWORD cInFilters,
    PF_FILTER_DESCRIPTOR* pfiltIn,
    DWORD cOutFilters,
    PF_FILTER_DESCRIPTOR* pfiltOut,
    void** pfHandle
);

パラメーター

名前方向
ihvoid*inout
cInFiltersDWORDin
pfiltInPF_FILTER_DESCRIPTOR*inout
cOutFiltersDWORDin
pfiltOutPF_FILTER_DESCRIPTOR*inout
pfHandlevoid**inout

戻り値の型: DWORD

各言語での呼び出し定義

// IPHLPAPI.dll
#include <windows.h>

DWORD PfAddFiltersToInterface(
    void* ih,
    DWORD cInFilters,
    PF_FILTER_DESCRIPTOR* pfiltIn,
    DWORD cOutFilters,
    PF_FILTER_DESCRIPTOR* pfiltOut,
    void** pfHandle
);
[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint PfAddFiltersToInterface(
    IntPtr ih,   // void* in/out
    uint cInFilters,   // DWORD
    IntPtr pfiltIn,   // PF_FILTER_DESCRIPTOR* in/out
    uint cOutFilters,   // DWORD
    IntPtr pfiltOut,   // PF_FILTER_DESCRIPTOR* in/out
    IntPtr pfHandle   // void** in/out
);
<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function PfAddFiltersToInterface(
    ih As IntPtr,   ' void* in/out
    cInFilters As UInteger,   ' DWORD
    pfiltIn As IntPtr,   ' PF_FILTER_DESCRIPTOR* in/out
    cOutFilters As UInteger,   ' DWORD
    pfiltOut As IntPtr,   ' PF_FILTER_DESCRIPTOR* in/out
    pfHandle As IntPtr   ' void** in/out
) As UInteger
End Function
' ih : void* in/out
' cInFilters : DWORD
' pfiltIn : PF_FILTER_DESCRIPTOR* in/out
' cOutFilters : DWORD
' pfiltOut : PF_FILTER_DESCRIPTOR* in/out
' pfHandle : void** in/out
Declare PtrSafe Function PfAddFiltersToInterface Lib "iphlpapi" ( _
    ByVal ih As LongPtr, _
    ByVal cInFilters As Long, _
    ByVal pfiltIn As LongPtr, _
    ByVal cOutFilters As Long, _
    ByVal pfiltOut As LongPtr, _
    ByVal pfHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PfAddFiltersToInterface = ctypes.windll.iphlpapi.PfAddFiltersToInterface
PfAddFiltersToInterface.restype = wintypes.DWORD
PfAddFiltersToInterface.argtypes = [
    ctypes.POINTER(None),  # ih : void* in/out
    wintypes.DWORD,  # cInFilters : DWORD
    ctypes.c_void_p,  # pfiltIn : PF_FILTER_DESCRIPTOR* in/out
    wintypes.DWORD,  # cOutFilters : DWORD
    ctypes.c_void_p,  # pfiltOut : PF_FILTER_DESCRIPTOR* in/out
    ctypes.c_void_p,  # pfHandle : void** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('IPHLPAPI.dll')
PfAddFiltersToInterface = Fiddle::Function.new(
  lib['PfAddFiltersToInterface'],
  [
    Fiddle::TYPE_VOIDP,  # ih : void* in/out
    -Fiddle::TYPE_INT,  # cInFilters : DWORD
    Fiddle::TYPE_VOIDP,  # pfiltIn : PF_FILTER_DESCRIPTOR* in/out
    -Fiddle::TYPE_INT,  # cOutFilters : DWORD
    Fiddle::TYPE_VOIDP,  # pfiltOut : PF_FILTER_DESCRIPTOR* in/out
    Fiddle::TYPE_VOIDP,  # pfHandle : void** in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "iphlpapi")]
extern "system" {
    fn PfAddFiltersToInterface(
        ih: *mut (),  // void* in/out
        cInFilters: u32,  // DWORD
        pfiltIn: *mut PF_FILTER_DESCRIPTOR,  // PF_FILTER_DESCRIPTOR* in/out
        cOutFilters: u32,  // DWORD
        pfiltOut: *mut PF_FILTER_DESCRIPTOR,  // PF_FILTER_DESCRIPTOR* in/out
        pfHandle: *mut *mut ()  // void** in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint PfAddFiltersToInterface(IntPtr ih, uint cInFilters, IntPtr pfiltIn, uint cOutFilters, IntPtr pfiltOut, IntPtr pfHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_PfAddFiltersToInterface' -Namespace Win32 -PassThru
# $api::PfAddFiltersToInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut, pfHandle)
#uselib "IPHLPAPI.dll"
#func global PfAddFiltersToInterface "PfAddFiltersToInterface" sptr, sptr, sptr, sptr, sptr, sptr
; PfAddFiltersToInterface ih, cInFilters, varptr(pfiltIn), cOutFilters, varptr(pfiltOut), pfHandle   ; 戻り値は stat
; ih : void* in/out -> "sptr"
; cInFilters : DWORD -> "sptr"
; pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> "sptr"
; cOutFilters : DWORD -> "sptr"
; pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> "sptr"
; pfHandle : void** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "IPHLPAPI.dll"
#cfunc global PfAddFiltersToInterface "PfAddFiltersToInterface" sptr, int, var, int, var, sptr
; res = PfAddFiltersToInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut, pfHandle)
; ih : void* in/out -> "sptr"
; cInFilters : DWORD -> "int"
; pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> "var"
; cOutFilters : DWORD -> "int"
; pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> "var"
; pfHandle : void** in/out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PfAddFiltersToInterface(void* ih, DWORD cInFilters, PF_FILTER_DESCRIPTOR* pfiltIn, DWORD cOutFilters, PF_FILTER_DESCRIPTOR* pfiltOut, void** pfHandle)
#uselib "IPHLPAPI.dll"
#cfunc global PfAddFiltersToInterface "PfAddFiltersToInterface" intptr, int, var, int, var, intptr
; res = PfAddFiltersToInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut, pfHandle)
; ih : void* in/out -> "intptr"
; cInFilters : DWORD -> "int"
; pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> "var"
; cOutFilters : DWORD -> "int"
; pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> "var"
; pfHandle : void** in/out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procPfAddFiltersToInterface = iphlpapi.NewProc("PfAddFiltersToInterface")
)

// ih (void* in/out), cInFilters (DWORD), pfiltIn (PF_FILTER_DESCRIPTOR* in/out), cOutFilters (DWORD), pfiltOut (PF_FILTER_DESCRIPTOR* in/out), pfHandle (void** in/out)
r1, _, err := procPfAddFiltersToInterface.Call(
	uintptr(ih),
	uintptr(cInFilters),
	uintptr(pfiltIn),
	uintptr(cOutFilters),
	uintptr(pfiltOut),
	uintptr(pfHandle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PfAddFiltersToInterface(
  ih: Pointer;   // void* in/out
  cInFilters: DWORD;   // DWORD
  pfiltIn: Pointer;   // PF_FILTER_DESCRIPTOR* in/out
  cOutFilters: DWORD;   // DWORD
  pfiltOut: Pointer;   // PF_FILTER_DESCRIPTOR* in/out
  pfHandle: Pointer   // void** in/out
): DWORD; stdcall;
  external 'IPHLPAPI.dll' name 'PfAddFiltersToInterface';
result := DllCall("IPHLPAPI\PfAddFiltersToInterface"
    , "Ptr", ih   ; void* in/out
    , "UInt", cInFilters   ; DWORD
    , "Ptr", pfiltIn   ; PF_FILTER_DESCRIPTOR* in/out
    , "UInt", cOutFilters   ; DWORD
    , "Ptr", pfiltOut   ; PF_FILTER_DESCRIPTOR* in/out
    , "Ptr", pfHandle   ; void** in/out
    , "UInt")   ; return: DWORD
●PfAddFiltersToInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut, pfHandle) = DLL("IPHLPAPI.dll", "dword PfAddFiltersToInterface(void*, dword, void*, dword, void*, void*)")
# 呼び出し: PfAddFiltersToInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut, pfHandle)
# ih : void* in/out -> "void*"
# cInFilters : DWORD -> "dword"
# pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> "void*"
# cOutFilters : DWORD -> "dword"
# pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> "void*"
# pfHandle : void** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。