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

FwpmSystemPortsSubscribe0

関数
WFPのシステムポート変更通知を購読する。
DLLfwpuclnt.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

DWORD FwpmSystemPortsSubscribe0(
    FWPM_ENGINE_HANDLE engineHandle,   // optional
    void* reserved,   // optional
    FWPM_SYSTEM_PORTS_CALLBACK0 callback,
    void* context,   // optional
    HANDLE* sysPortsHandle
);

パラメーター

名前方向説明
engineHandleFWPM_ENGINE_HANDLEinoptionalフィルタリングエンジンへのセッションハンドル。
reservedvoid*optional将来の使用のために予約。NULLを指定する。
callbackFWPM_SYSTEM_PORTS_CALLBACK0inシステムポート変更時に呼ばれるFWPM_SYSTEM_PORTS_CALLBACK0。
contextvoid*inoptionalコールバックへそのまま渡される任意のユーザーコンテキスト。NULL可。
sysPortsHandleHANDLE*out登録されたシステムポート通知のハンドルを受け取る出力。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD FwpmSystemPortsSubscribe0(
    FWPM_ENGINE_HANDLE engineHandle,   // optional
    void* reserved,   // optional
    FWPM_SYSTEM_PORTS_CALLBACK0 callback,
    void* context,   // optional
    HANDLE* sysPortsHandle
);
[DllImport("fwpuclnt.dll", ExactSpelling = true)]
static extern uint FwpmSystemPortsSubscribe0(
    FWPM_ENGINE_HANDLE engineHandle,   // FWPM_ENGINE_HANDLE optional
    IntPtr reserved,   // void* optional
    IntPtr callback,   // FWPM_SYSTEM_PORTS_CALLBACK0
    IntPtr context,   // void* optional
    IntPtr sysPortsHandle   // HANDLE* out
);
<DllImport("fwpuclnt.dll", ExactSpelling:=True)>
Public Shared Function FwpmSystemPortsSubscribe0(
    engineHandle As FWPM_ENGINE_HANDLE,   ' FWPM_ENGINE_HANDLE optional
    reserved As IntPtr,   ' void* optional
    callback As IntPtr,   ' FWPM_SYSTEM_PORTS_CALLBACK0
    context As IntPtr,   ' void* optional
    sysPortsHandle As IntPtr   ' HANDLE* out
) As UInteger
End Function
' engineHandle : FWPM_ENGINE_HANDLE optional
' reserved : void* optional
' callback : FWPM_SYSTEM_PORTS_CALLBACK0
' context : void* optional
' sysPortsHandle : HANDLE* out
Declare PtrSafe Function FwpmSystemPortsSubscribe0 Lib "fwpuclnt" ( _
    ByVal engineHandle As LongPtr, _
    ByVal reserved As LongPtr, _
    ByVal callback As LongPtr, _
    ByVal context As LongPtr, _
    ByVal sysPortsHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

FwpmSystemPortsSubscribe0 = ctypes.windll.fwpuclnt.FwpmSystemPortsSubscribe0
FwpmSystemPortsSubscribe0.restype = wintypes.DWORD
FwpmSystemPortsSubscribe0.argtypes = [
    FWPM_ENGINE_HANDLE,  # engineHandle : FWPM_ENGINE_HANDLE optional
    ctypes.POINTER(None),  # reserved : void* optional
    ctypes.c_void_p,  # callback : FWPM_SYSTEM_PORTS_CALLBACK0
    ctypes.POINTER(None),  # context : void* optional
    ctypes.c_void_p,  # sysPortsHandle : HANDLE* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('fwpuclnt.dll')
FwpmSystemPortsSubscribe0 = Fiddle::Function.new(
  lib['FwpmSystemPortsSubscribe0'],
  [
    Fiddle::TYPE_VOIDP,  # engineHandle : FWPM_ENGINE_HANDLE optional
    Fiddle::TYPE_VOIDP,  # reserved : void* optional
    Fiddle::TYPE_VOIDP,  # callback : FWPM_SYSTEM_PORTS_CALLBACK0
    Fiddle::TYPE_VOIDP,  # context : void* optional
    Fiddle::TYPE_VOIDP,  # sysPortsHandle : HANDLE* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "fwpuclnt")]
extern "system" {
    fn FwpmSystemPortsSubscribe0(
        engineHandle: FWPM_ENGINE_HANDLE,  // FWPM_ENGINE_HANDLE optional
        reserved: *mut (),  // void* optional
        callback: *const core::ffi::c_void,  // FWPM_SYSTEM_PORTS_CALLBACK0
        context: *mut (),  // void* optional
        sysPortsHandle: *mut *mut core::ffi::c_void  // HANDLE* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("fwpuclnt.dll")]
public static extern uint FwpmSystemPortsSubscribe0(FWPM_ENGINE_HANDLE engineHandle, IntPtr reserved, IntPtr callback, IntPtr context, IntPtr sysPortsHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'fwpuclnt_FwpmSystemPortsSubscribe0' -Namespace Win32 -PassThru
# $api::FwpmSystemPortsSubscribe0(engineHandle, reserved, callback, context, sysPortsHandle)
#uselib "fwpuclnt.dll"
#func global FwpmSystemPortsSubscribe0 "FwpmSystemPortsSubscribe0" sptr, sptr, sptr, sptr, sptr
; FwpmSystemPortsSubscribe0 engineHandle, reserved, callback, context, sysPortsHandle   ; 戻り値は stat
; engineHandle : FWPM_ENGINE_HANDLE optional -> "sptr"
; reserved : void* optional -> "sptr"
; callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> "sptr"
; context : void* optional -> "sptr"
; sysPortsHandle : HANDLE* out -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "fwpuclnt.dll"
#cfunc global FwpmSystemPortsSubscribe0 "FwpmSystemPortsSubscribe0" int, sptr, sptr, sptr, sptr
; res = FwpmSystemPortsSubscribe0(engineHandle, reserved, callback, context, sysPortsHandle)
; engineHandle : FWPM_ENGINE_HANDLE optional -> "int"
; reserved : void* optional -> "sptr"
; callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> "sptr"
; context : void* optional -> "sptr"
; sysPortsHandle : HANDLE* out -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; DWORD FwpmSystemPortsSubscribe0(FWPM_ENGINE_HANDLE engineHandle, void* reserved, FWPM_SYSTEM_PORTS_CALLBACK0 callback, void* context, HANDLE* sysPortsHandle)
#uselib "fwpuclnt.dll"
#cfunc global FwpmSystemPortsSubscribe0 "FwpmSystemPortsSubscribe0" int, intptr, intptr, intptr, intptr
; res = FwpmSystemPortsSubscribe0(engineHandle, reserved, callback, context, sysPortsHandle)
; engineHandle : FWPM_ENGINE_HANDLE optional -> "int"
; reserved : void* optional -> "intptr"
; callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> "intptr"
; context : void* optional -> "intptr"
; sysPortsHandle : HANDLE* out -> "intptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	fwpuclnt = windows.NewLazySystemDLL("fwpuclnt.dll")
	procFwpmSystemPortsSubscribe0 = fwpuclnt.NewProc("FwpmSystemPortsSubscribe0")
)

// engineHandle (FWPM_ENGINE_HANDLE optional), reserved (void* optional), callback (FWPM_SYSTEM_PORTS_CALLBACK0), context (void* optional), sysPortsHandle (HANDLE* out)
r1, _, err := procFwpmSystemPortsSubscribe0.Call(
	uintptr(engineHandle),
	uintptr(reserved),
	uintptr(callback),
	uintptr(context),
	uintptr(sysPortsHandle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function FwpmSystemPortsSubscribe0(
  engineHandle: FWPM_ENGINE_HANDLE;   // FWPM_ENGINE_HANDLE optional
  reserved: Pointer;   // void* optional
  callback: Pointer;   // FWPM_SYSTEM_PORTS_CALLBACK0
  context: Pointer;   // void* optional
  sysPortsHandle: Pointer   // HANDLE* out
): DWORD; stdcall;
  external 'fwpuclnt.dll' name 'FwpmSystemPortsSubscribe0';
result := DllCall("fwpuclnt\FwpmSystemPortsSubscribe0"
    , "Ptr", engineHandle   ; FWPM_ENGINE_HANDLE optional
    , "Ptr", reserved   ; void* optional
    , "Ptr", callback   ; FWPM_SYSTEM_PORTS_CALLBACK0
    , "Ptr", context   ; void* optional
    , "Ptr", sysPortsHandle   ; HANDLE* out
    , "UInt")   ; return: DWORD
●FwpmSystemPortsSubscribe0(engineHandle, reserved, callback, context, sysPortsHandle) = DLL("fwpuclnt.dll", "dword FwpmSystemPortsSubscribe0(void*, void*, void*, void*, void*)")
# 呼び出し: FwpmSystemPortsSubscribe0(engineHandle, reserved, callback, context, sysPortsHandle)
# engineHandle : FWPM_ENGINE_HANDLE optional -> "void*"
# reserved : void* optional -> "void*"
# callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> "void*"
# context : void* optional -> "void*"
# sysPortsHandle : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "fwpuclnt" fn FwpmSystemPortsSubscribe0(
    engineHandle: FWPM_ENGINE_HANDLE, // FWPM_ENGINE_HANDLE optional
    reserved: ?*anyopaque, // void* optional
    callback: ?*anyopaque, // FWPM_SYSTEM_PORTS_CALLBACK0
    context: ?*anyopaque, // void* optional
    sysPortsHandle: ?*anyopaque // HANDLE* out
) callconv(std.os.windows.WINAPI) u32;
proc FwpmSystemPortsSubscribe0(
    engineHandle: FWPM_ENGINE_HANDLE,  # FWPM_ENGINE_HANDLE optional
    reserved: pointer,  # void* optional
    callback: pointer,  # FWPM_SYSTEM_PORTS_CALLBACK0
    context: pointer,  # void* optional
    sysPortsHandle: pointer  # HANDLE* out
): uint32 {.importc: "FwpmSystemPortsSubscribe0", stdcall, dynlib: "fwpuclnt.dll".}
pragma(lib, "fwpuclnt");
extern(Windows)
uint FwpmSystemPortsSubscribe0(
    FWPM_ENGINE_HANDLE engineHandle,   // FWPM_ENGINE_HANDLE optional
    void* reserved,   // void* optional
    void* callback,   // FWPM_SYSTEM_PORTS_CALLBACK0
    void* context,   // void* optional
    void* sysPortsHandle   // HANDLE* out
);
ccall((:FwpmSystemPortsSubscribe0, "fwpuclnt.dll"), stdcall, UInt32,
      (FWPM_ENGINE_HANDLE, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
      engineHandle, reserved, callback, context, sysPortsHandle)
# engineHandle : FWPM_ENGINE_HANDLE optional -> FWPM_ENGINE_HANDLE
# reserved : void* optional -> Ptr{Cvoid}
# callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> Ptr{Cvoid}
# context : void* optional -> Ptr{Cvoid}
# sysPortsHandle : HANDLE* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t FwpmSystemPortsSubscribe0(
    FWPM_ENGINE_HANDLE engineHandle,
    void* reserved,
    void* callback,
    void* context,
    void* sysPortsHandle);
]]
local fwpuclnt = ffi.load("fwpuclnt")
-- fwpuclnt.FwpmSystemPortsSubscribe0(engineHandle, reserved, callback, context, sysPortsHandle)
-- engineHandle : FWPM_ENGINE_HANDLE optional
-- reserved : void* optional
-- callback : FWPM_SYSTEM_PORTS_CALLBACK0
-- context : void* optional
-- sysPortsHandle : HANDLE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('fwpuclnt.dll');
const FwpmSystemPortsSubscribe0 = lib.func('__stdcall', 'FwpmSystemPortsSubscribe0', 'uint32_t', ['FWPM_ENGINE_HANDLE', 'void *', 'void *', 'void *', 'void *']);
// FwpmSystemPortsSubscribe0(engineHandle, reserved, callback, context, sysPortsHandle)
// engineHandle : FWPM_ENGINE_HANDLE optional -> 'FWPM_ENGINE_HANDLE'
// reserved : void* optional -> 'void *'
// callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> 'void *'
// context : void* optional -> 'void *'
// sysPortsHandle : HANDLE* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("fwpuclnt.dll", {
  FwpmSystemPortsSubscribe0: { parameters: ["buffer", "pointer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.FwpmSystemPortsSubscribe0(engineHandle, reserved, callback, context, sysPortsHandle)
// engineHandle : FWPM_ENGINE_HANDLE optional -> "buffer"
// reserved : void* optional -> "pointer"
// callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> "pointer"
// context : void* optional -> "pointer"
// sysPortsHandle : HANDLE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t FwpmSystemPortsSubscribe0(
    FWPM_ENGINE_HANDLE engineHandle,
    void* reserved,
    void* callback,
    void* context,
    void* sysPortsHandle);
C, "fwpuclnt.dll");
// $ffi->FwpmSystemPortsSubscribe0(engineHandle, reserved, callback, context, sysPortsHandle);
// engineHandle : FWPM_ENGINE_HANDLE optional
// reserved : void* optional
// callback : FWPM_SYSTEM_PORTS_CALLBACK0
// context : void* optional
// sysPortsHandle : HANDLE* 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 Fwpuclnt extends StdCallLibrary {
    Fwpuclnt INSTANCE = Native.load("fwpuclnt", Fwpuclnt.class);
    int FwpmSystemPortsSubscribe0(
        FWPM_ENGINE_HANDLE /* extends Structure (by value) */ engineHandle,   // FWPM_ENGINE_HANDLE optional
        Pointer reserved,   // void* optional
        Callback callback,   // FWPM_SYSTEM_PORTS_CALLBACK0
        Pointer context,   // void* optional
        Pointer sysPortsHandle   // HANDLE* out
    );
}
@[Link("fwpuclnt")]
lib Libfwpuclnt
  fun FwpmSystemPortsSubscribe0 = FwpmSystemPortsSubscribe0(
    engineHandle : FWPM_ENGINE_HANDLE,   # FWPM_ENGINE_HANDLE optional
    reserved : Void*,   # void* optional
    callback : Void*,   # FWPM_SYSTEM_PORTS_CALLBACK0
    context : Void*,   # void* optional
    sysPortsHandle : Void*   # HANDLE* out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef FwpmSystemPortsSubscribe0Native = Uint32 Function(FWPM_ENGINE_HANDLE, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef FwpmSystemPortsSubscribe0Dart = int Function(int, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final FwpmSystemPortsSubscribe0 = DynamicLibrary.open('fwpuclnt.dll')
    .lookupFunction<FwpmSystemPortsSubscribe0Native, FwpmSystemPortsSubscribe0Dart>('FwpmSystemPortsSubscribe0');
// engineHandle : FWPM_ENGINE_HANDLE optional -> FWPM_ENGINE_HANDLE
// reserved : void* optional -> Pointer<Void>
// callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> Pointer<Void>
// context : void* optional -> Pointer<Void>
// sysPortsHandle : HANDLE* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function FwpmSystemPortsSubscribe0(
  engineHandle: FWPM_ENGINE_HANDLE;   // FWPM_ENGINE_HANDLE optional
  reserved: Pointer;   // void* optional
  callback: Pointer;   // FWPM_SYSTEM_PORTS_CALLBACK0
  context: Pointer;   // void* optional
  sysPortsHandle: Pointer   // HANDLE* out
): DWORD; stdcall;
  external 'fwpuclnt.dll' name 'FwpmSystemPortsSubscribe0';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "FwpmSystemPortsSubscribe0"
  c_FwpmSystemPortsSubscribe0 :: FWPM_ENGINE_HANDLE -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO Word32
-- engineHandle : FWPM_ENGINE_HANDLE optional -> FWPM_ENGINE_HANDLE
-- reserved : void* optional -> Ptr ()
-- callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> Ptr ()
-- context : void* optional -> Ptr ()
-- sysPortsHandle : HANDLE* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。
open Ctypes
open Foreign

let fwpmsystemportssubscribe0 =
  foreign "FwpmSystemPortsSubscribe0"
    (FWPM_ENGINE_HANDLE @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* engineHandle : FWPM_ENGINE_HANDLE optional -> FWPM_ENGINE_HANDLE *)
(* reserved : void* optional -> (ptr void) *)
(* callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> (ptr void) *)
(* context : void* optional -> (ptr void) *)
(* sysPortsHandle : HANDLE* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library fwpuclnt (t "fwpuclnt.dll"))
(cffi:use-foreign-library fwpuclnt)

(cffi:defcfun ("FwpmSystemPortsSubscribe0" fwpm-system-ports-subscribe0 :convention :stdcall) :uint32
  (engine-handle (:struct fwpm-engine-handle))   ; FWPM_ENGINE_HANDLE optional
  (reserved :pointer)   ; void* optional
  (callback :pointer)   ; FWPM_SYSTEM_PORTS_CALLBACK0
  (context :pointer)   ; void* optional
  (sys-ports-handle :pointer))   ; HANDLE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $FwpmSystemPortsSubscribe0 = Win32::API::More->new('fwpuclnt',
    'DWORD FwpmSystemPortsSubscribe0(LPVOID engineHandle, LPVOID reserved, LPVOID callback, LPVOID context, HANDLE sysPortsHandle)');
# my $ret = $FwpmSystemPortsSubscribe0->Call($engineHandle, $reserved, $callback, $context, $sysPortsHandle);
# engineHandle : FWPM_ENGINE_HANDLE optional -> LPVOID
# reserved : void* optional -> LPVOID
# callback : FWPM_SYSTEM_PORTS_CALLBACK0 -> LPVOID
# context : void* optional -> LPVOID
# sysPortsHandle : HANDLE* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型