ホーム › NetworkManagement.IpHelper › PfRemoveFiltersFromInterface
PfRemoveFiltersFromInterface
関数インターフェイスから送受信パケットフィルタを削除する。
シグネチャ
// IPHLPAPI.dll
#include <windows.h>
DWORD PfRemoveFiltersFromInterface(
void* ih,
DWORD cInFilters,
PF_FILTER_DESCRIPTOR* pfiltIn,
DWORD cOutFilters,
PF_FILTER_DESCRIPTOR* pfiltOut
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ih | void* | inout | フィルタを削除する対象インターフェースのハンドル。 |
| cInFilters | DWORD | in | pfiltInが指す受信フィルタ配列の要素数。 |
| pfiltIn | PF_FILTER_DESCRIPTOR* | inout | 削除する受信方向フィルタを記述したPF_FILTER_DESCRIPTOR配列。なければNULL可。 |
| cOutFilters | DWORD | in | pfiltOutが指す送信フィルタ配列の要素数。 |
| pfiltOut | PF_FILTER_DESCRIPTOR* | inout | 削除する送信方向フィルタを記述したPF_FILTER_DESCRIPTOR配列。なければNULL可。 |
戻り値の型: DWORD
各言語での呼び出し定義
// IPHLPAPI.dll
#include <windows.h>
DWORD PfRemoveFiltersFromInterface(
void* ih,
DWORD cInFilters,
PF_FILTER_DESCRIPTOR* pfiltIn,
DWORD cOutFilters,
PF_FILTER_DESCRIPTOR* pfiltOut
);[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint PfRemoveFiltersFromInterface(
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
);<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function PfRemoveFiltersFromInterface(
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
) As UInteger
End Function' ih : void* in/out
' cInFilters : DWORD
' pfiltIn : PF_FILTER_DESCRIPTOR* in/out
' cOutFilters : DWORD
' pfiltOut : PF_FILTER_DESCRIPTOR* in/out
Declare PtrSafe Function PfRemoveFiltersFromInterface Lib "iphlpapi" ( _
ByVal ih As LongPtr, _
ByVal cInFilters As Long, _
ByVal pfiltIn As LongPtr, _
ByVal cOutFilters As Long, _
ByVal pfiltOut As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PfRemoveFiltersFromInterface = ctypes.windll.iphlpapi.PfRemoveFiltersFromInterface
PfRemoveFiltersFromInterface.restype = wintypes.DWORD
PfRemoveFiltersFromInterface.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
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('IPHLPAPI.dll')
PfRemoveFiltersFromInterface = Fiddle::Function.new(
lib['PfRemoveFiltersFromInterface'],
[
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_INT)#[link(name = "iphlpapi")]
extern "system" {
fn PfRemoveFiltersFromInterface(
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
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint PfRemoveFiltersFromInterface(IntPtr ih, uint cInFilters, IntPtr pfiltIn, uint cOutFilters, IntPtr pfiltOut);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_PfRemoveFiltersFromInterface' -Namespace Win32 -PassThru
# $api::PfRemoveFiltersFromInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut)#uselib "IPHLPAPI.dll"
#func global PfRemoveFiltersFromInterface "PfRemoveFiltersFromInterface" sptr, sptr, sptr, sptr, sptr
; PfRemoveFiltersFromInterface ih, cInFilters, varptr(pfiltIn), cOutFilters, varptr(pfiltOut) ; 戻り値は 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"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "IPHLPAPI.dll" #cfunc global PfRemoveFiltersFromInterface "PfRemoveFiltersFromInterface" sptr, int, var, int, var ; res = PfRemoveFiltersFromInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut) ; 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" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "IPHLPAPI.dll" #cfunc global PfRemoveFiltersFromInterface "PfRemoveFiltersFromInterface" sptr, int, sptr, int, sptr ; res = PfRemoveFiltersFromInterface(ih, cInFilters, varptr(pfiltIn), cOutFilters, varptr(pfiltOut)) ; ih : void* in/out -> "sptr" ; cInFilters : DWORD -> "int" ; pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> "sptr" ; cOutFilters : DWORD -> "int" ; pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD PfRemoveFiltersFromInterface(void* ih, DWORD cInFilters, PF_FILTER_DESCRIPTOR* pfiltIn, DWORD cOutFilters, PF_FILTER_DESCRIPTOR* pfiltOut) #uselib "IPHLPAPI.dll" #cfunc global PfRemoveFiltersFromInterface "PfRemoveFiltersFromInterface" intptr, int, var, int, var ; res = PfRemoveFiltersFromInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut) ; 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" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD PfRemoveFiltersFromInterface(void* ih, DWORD cInFilters, PF_FILTER_DESCRIPTOR* pfiltIn, DWORD cOutFilters, PF_FILTER_DESCRIPTOR* pfiltOut) #uselib "IPHLPAPI.dll" #cfunc global PfRemoveFiltersFromInterface "PfRemoveFiltersFromInterface" intptr, int, intptr, int, intptr ; res = PfRemoveFiltersFromInterface(ih, cInFilters, varptr(pfiltIn), cOutFilters, varptr(pfiltOut)) ; ih : void* in/out -> "intptr" ; cInFilters : DWORD -> "int" ; pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> "intptr" ; cOutFilters : DWORD -> "int" ; pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
procPfRemoveFiltersFromInterface = iphlpapi.NewProc("PfRemoveFiltersFromInterface")
)
// ih (void* in/out), cInFilters (DWORD), pfiltIn (PF_FILTER_DESCRIPTOR* in/out), cOutFilters (DWORD), pfiltOut (PF_FILTER_DESCRIPTOR* in/out)
r1, _, err := procPfRemoveFiltersFromInterface.Call(
uintptr(ih),
uintptr(cInFilters),
uintptr(pfiltIn),
uintptr(cOutFilters),
uintptr(pfiltOut),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PfRemoveFiltersFromInterface(
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
): DWORD; stdcall;
external 'IPHLPAPI.dll' name 'PfRemoveFiltersFromInterface';result := DllCall("IPHLPAPI\PfRemoveFiltersFromInterface"
, "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
, "UInt") ; return: DWORD●PfRemoveFiltersFromInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut) = DLL("IPHLPAPI.dll", "dword PfRemoveFiltersFromInterface(void*, dword, void*, dword, void*)")
# 呼び出し: PfRemoveFiltersFromInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut)
# 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*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "iphlpapi" fn PfRemoveFiltersFromInterface(
ih: ?*anyopaque, // void* in/out
cInFilters: u32, // DWORD
pfiltIn: [*c]PF_FILTER_DESCRIPTOR, // PF_FILTER_DESCRIPTOR* in/out
cOutFilters: u32, // DWORD
pfiltOut: [*c]PF_FILTER_DESCRIPTOR // PF_FILTER_DESCRIPTOR* in/out
) callconv(std.os.windows.WINAPI) u32;proc PfRemoveFiltersFromInterface(
ih: pointer, # void* in/out
cInFilters: uint32, # DWORD
pfiltIn: ptr PF_FILTER_DESCRIPTOR, # PF_FILTER_DESCRIPTOR* in/out
cOutFilters: uint32, # DWORD
pfiltOut: ptr PF_FILTER_DESCRIPTOR # PF_FILTER_DESCRIPTOR* in/out
): uint32 {.importc: "PfRemoveFiltersFromInterface", stdcall, dynlib: "IPHLPAPI.dll".}pragma(lib, "iphlpapi");
extern(Windows)
uint PfRemoveFiltersFromInterface(
void* ih, // void* in/out
uint cInFilters, // DWORD
PF_FILTER_DESCRIPTOR* pfiltIn, // PF_FILTER_DESCRIPTOR* in/out
uint cOutFilters, // DWORD
PF_FILTER_DESCRIPTOR* pfiltOut // PF_FILTER_DESCRIPTOR* in/out
);ccall((:PfRemoveFiltersFromInterface, "IPHLPAPI.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32, Ptr{PF_FILTER_DESCRIPTOR}, UInt32, Ptr{PF_FILTER_DESCRIPTOR}),
ih, cInFilters, pfiltIn, cOutFilters, pfiltOut)
# ih : void* in/out -> Ptr{Cvoid}
# cInFilters : DWORD -> UInt32
# pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> Ptr{PF_FILTER_DESCRIPTOR}
# cOutFilters : DWORD -> UInt32
# pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> Ptr{PF_FILTER_DESCRIPTOR}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t PfRemoveFiltersFromInterface(
void* ih,
uint32_t cInFilters,
void* pfiltIn,
uint32_t cOutFilters,
void* pfiltOut);
]]
local iphlpapi = ffi.load("iphlpapi")
-- iphlpapi.PfRemoveFiltersFromInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut)
-- ih : void* in/out
-- cInFilters : DWORD
-- pfiltIn : PF_FILTER_DESCRIPTOR* in/out
-- cOutFilters : DWORD
-- pfiltOut : PF_FILTER_DESCRIPTOR* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('IPHLPAPI.dll');
const PfRemoveFiltersFromInterface = lib.func('__stdcall', 'PfRemoveFiltersFromInterface', 'uint32_t', ['void *', 'uint32_t', 'void *', 'uint32_t', 'void *']);
// PfRemoveFiltersFromInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut)
// ih : void* in/out -> 'void *'
// cInFilters : DWORD -> 'uint32_t'
// pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> 'void *'
// cOutFilters : DWORD -> 'uint32_t'
// pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("IPHLPAPI.dll", {
PfRemoveFiltersFromInterface: { parameters: ["pointer", "u32", "pointer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.PfRemoveFiltersFromInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut)
// ih : void* in/out -> "pointer"
// cInFilters : DWORD -> "u32"
// pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> "pointer"
// cOutFilters : DWORD -> "u32"
// pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t PfRemoveFiltersFromInterface(
void* ih,
uint32_t cInFilters,
void* pfiltIn,
uint32_t cOutFilters,
void* pfiltOut);
C, "IPHLPAPI.dll");
// $ffi->PfRemoveFiltersFromInterface(ih, cInFilters, pfiltIn, cOutFilters, pfiltOut);
// ih : void* in/out
// cInFilters : DWORD
// pfiltIn : PF_FILTER_DESCRIPTOR* in/out
// cOutFilters : DWORD
// pfiltOut : PF_FILTER_DESCRIPTOR* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Iphlpapi extends StdCallLibrary {
Iphlpapi INSTANCE = Native.load("iphlpapi", Iphlpapi.class);
int PfRemoveFiltersFromInterface(
Pointer ih, // void* in/out
int cInFilters, // DWORD
Pointer pfiltIn, // PF_FILTER_DESCRIPTOR* in/out
int cOutFilters, // DWORD
Pointer pfiltOut // PF_FILTER_DESCRIPTOR* in/out
);
}@[Link("iphlpapi")]
lib LibIPHLPAPI
fun PfRemoveFiltersFromInterface = PfRemoveFiltersFromInterface(
ih : Void*, # void* in/out
cInFilters : UInt32, # DWORD
pfiltIn : PF_FILTER_DESCRIPTOR*, # PF_FILTER_DESCRIPTOR* in/out
cOutFilters : UInt32, # DWORD
pfiltOut : PF_FILTER_DESCRIPTOR* # PF_FILTER_DESCRIPTOR* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PfRemoveFiltersFromInterfaceNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Void>, Uint32, Pointer<Void>);
typedef PfRemoveFiltersFromInterfaceDart = int Function(Pointer<Void>, int, Pointer<Void>, int, Pointer<Void>);
final PfRemoveFiltersFromInterface = DynamicLibrary.open('IPHLPAPI.dll')
.lookupFunction<PfRemoveFiltersFromInterfaceNative, PfRemoveFiltersFromInterfaceDart>('PfRemoveFiltersFromInterface');
// ih : void* in/out -> Pointer<Void>
// cInFilters : DWORD -> Uint32
// pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> Pointer<Void>
// cOutFilters : DWORD -> Uint32
// pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PfRemoveFiltersFromInterface(
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
): DWORD; stdcall;
external 'IPHLPAPI.dll' name 'PfRemoveFiltersFromInterface';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PfRemoveFiltersFromInterface"
c_PfRemoveFiltersFromInterface :: Ptr () -> Word32 -> Ptr () -> Word32 -> Ptr () -> IO Word32
-- ih : void* in/out -> Ptr ()
-- cInFilters : DWORD -> Word32
-- pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> Ptr ()
-- cOutFilters : DWORD -> Word32
-- pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let pfremovefiltersfrominterface =
foreign "PfRemoveFiltersFromInterface"
((ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* ih : void* in/out -> (ptr void) *)
(* cInFilters : DWORD -> uint32_t *)
(* pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> (ptr void) *)
(* cOutFilters : DWORD -> uint32_t *)
(* pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library iphlpapi (t "IPHLPAPI.dll"))
(cffi:use-foreign-library iphlpapi)
(cffi:defcfun ("PfRemoveFiltersFromInterface" pf-remove-filters-from-interface :convention :stdcall) :uint32
(ih :pointer) ; void* in/out
(c-in-filters :uint32) ; DWORD
(pfilt-in :pointer) ; PF_FILTER_DESCRIPTOR* in/out
(c-out-filters :uint32) ; DWORD
(pfilt-out :pointer)) ; PF_FILTER_DESCRIPTOR* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PfRemoveFiltersFromInterface = Win32::API::More->new('IPHLPAPI',
'DWORD PfRemoveFiltersFromInterface(LPVOID ih, DWORD cInFilters, LPVOID pfiltIn, DWORD cOutFilters, LPVOID pfiltOut)');
# my $ret = $PfRemoveFiltersFromInterface->Call($ih, $cInFilters, $pfiltIn, $cOutFilters, $pfiltOut);
# ih : void* in/out -> LPVOID
# cInFilters : DWORD -> DWORD
# pfiltIn : PF_FILTER_DESCRIPTOR* in/out -> LPVOID
# cOutFilters : DWORD -> DWORD
# pfiltOut : PF_FILTER_DESCRIPTOR* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。