ホーム › Networking.WinSock › WSAQuerySocketSecurity
WSAQuerySocketSecurity
関数ソケットに適用されたセキュリティ情報を照会する。
シグネチャ
// fwpuclnt.dll
#include <windows.h>
INT WSAQuerySocketSecurity(
SOCKET Socket,
const SOCKET_SECURITY_QUERY_TEMPLATE* SecurityQueryTemplate, // optional
DWORD SecurityQueryTemplateLen,
SOCKET_SECURITY_QUERY_INFO* SecurityQueryInfo, // optional
DWORD* SecurityQueryInfoLen,
OVERLAPPED* Overlapped, // optional
LPWSAOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Socket | SOCKET | in |
| SecurityQueryTemplate | SOCKET_SECURITY_QUERY_TEMPLATE* | inoptional |
| SecurityQueryTemplateLen | DWORD | in |
| SecurityQueryInfo | SOCKET_SECURITY_QUERY_INFO* | outoptional |
| SecurityQueryInfoLen | DWORD* | inout |
| Overlapped | OVERLAPPED* | inoptional |
| CompletionRoutine | LPWSAOVERLAPPED_COMPLETION_ROUTINE | inoptional |
戻り値の型: INT
各言語での呼び出し定義
// fwpuclnt.dll
#include <windows.h>
INT WSAQuerySocketSecurity(
SOCKET Socket,
const SOCKET_SECURITY_QUERY_TEMPLATE* SecurityQueryTemplate, // optional
DWORD SecurityQueryTemplateLen,
SOCKET_SECURITY_QUERY_INFO* SecurityQueryInfo, // optional
DWORD* SecurityQueryInfoLen,
OVERLAPPED* Overlapped, // optional
LPWSAOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine // optional
);[DllImport("fwpuclnt.dll", SetLastError = true, ExactSpelling = true)]
static extern int WSAQuerySocketSecurity(
UIntPtr Socket, // SOCKET
IntPtr SecurityQueryTemplate, // SOCKET_SECURITY_QUERY_TEMPLATE* optional
uint SecurityQueryTemplateLen, // DWORD
IntPtr SecurityQueryInfo, // SOCKET_SECURITY_QUERY_INFO* optional, out
ref uint SecurityQueryInfoLen, // DWORD* in/out
IntPtr Overlapped, // OVERLAPPED* optional
IntPtr CompletionRoutine // LPWSAOVERLAPPED_COMPLETION_ROUTINE optional
);<DllImport("fwpuclnt.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WSAQuerySocketSecurity(
Socket As UIntPtr, ' SOCKET
SecurityQueryTemplate As IntPtr, ' SOCKET_SECURITY_QUERY_TEMPLATE* optional
SecurityQueryTemplateLen As UInteger, ' DWORD
SecurityQueryInfo As IntPtr, ' SOCKET_SECURITY_QUERY_INFO* optional, out
ByRef SecurityQueryInfoLen As UInteger, ' DWORD* in/out
Overlapped As IntPtr, ' OVERLAPPED* optional
CompletionRoutine As IntPtr ' LPWSAOVERLAPPED_COMPLETION_ROUTINE optional
) As Integer
End Function' Socket : SOCKET
' SecurityQueryTemplate : SOCKET_SECURITY_QUERY_TEMPLATE* optional
' SecurityQueryTemplateLen : DWORD
' SecurityQueryInfo : SOCKET_SECURITY_QUERY_INFO* optional, out
' SecurityQueryInfoLen : DWORD* in/out
' Overlapped : OVERLAPPED* optional
' CompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE optional
Declare PtrSafe Function WSAQuerySocketSecurity Lib "fwpuclnt" ( _
ByVal Socket As LongPtr, _
ByVal SecurityQueryTemplate As LongPtr, _
ByVal SecurityQueryTemplateLen As Long, _
ByVal SecurityQueryInfo As LongPtr, _
ByRef SecurityQueryInfoLen As Long, _
ByVal Overlapped As LongPtr, _
ByVal CompletionRoutine As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WSAQuerySocketSecurity = ctypes.windll.fwpuclnt.WSAQuerySocketSecurity
WSAQuerySocketSecurity.restype = ctypes.c_int
WSAQuerySocketSecurity.argtypes = [
ctypes.c_size_t, # Socket : SOCKET
ctypes.c_void_p, # SecurityQueryTemplate : SOCKET_SECURITY_QUERY_TEMPLATE* optional
wintypes.DWORD, # SecurityQueryTemplateLen : DWORD
ctypes.c_void_p, # SecurityQueryInfo : SOCKET_SECURITY_QUERY_INFO* optional, out
ctypes.POINTER(wintypes.DWORD), # SecurityQueryInfoLen : DWORD* in/out
ctypes.c_void_p, # Overlapped : OVERLAPPED* optional
ctypes.c_void_p, # CompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('fwpuclnt.dll')
WSAQuerySocketSecurity = Fiddle::Function.new(
lib['WSAQuerySocketSecurity'],
[
Fiddle::TYPE_UINTPTR_T, # Socket : SOCKET
Fiddle::TYPE_VOIDP, # SecurityQueryTemplate : SOCKET_SECURITY_QUERY_TEMPLATE* optional
-Fiddle::TYPE_INT, # SecurityQueryTemplateLen : DWORD
Fiddle::TYPE_VOIDP, # SecurityQueryInfo : SOCKET_SECURITY_QUERY_INFO* optional, out
Fiddle::TYPE_VOIDP, # SecurityQueryInfoLen : DWORD* in/out
Fiddle::TYPE_VOIDP, # Overlapped : OVERLAPPED* optional
Fiddle::TYPE_VOIDP, # CompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE optional
],
Fiddle::TYPE_INT)#[link(name = "fwpuclnt")]
extern "system" {
fn WSAQuerySocketSecurity(
Socket: usize, // SOCKET
SecurityQueryTemplate: *const SOCKET_SECURITY_QUERY_TEMPLATE, // SOCKET_SECURITY_QUERY_TEMPLATE* optional
SecurityQueryTemplateLen: u32, // DWORD
SecurityQueryInfo: *mut SOCKET_SECURITY_QUERY_INFO, // SOCKET_SECURITY_QUERY_INFO* optional, out
SecurityQueryInfoLen: *mut u32, // DWORD* in/out
Overlapped: *mut OVERLAPPED, // OVERLAPPED* optional
CompletionRoutine: *const core::ffi::c_void // LPWSAOVERLAPPED_COMPLETION_ROUTINE optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("fwpuclnt.dll", SetLastError = true)]
public static extern int WSAQuerySocketSecurity(UIntPtr Socket, IntPtr SecurityQueryTemplate, uint SecurityQueryTemplateLen, IntPtr SecurityQueryInfo, ref uint SecurityQueryInfoLen, IntPtr Overlapped, IntPtr CompletionRoutine);
"@
$api = Add-Type -MemberDefinition $sig -Name 'fwpuclnt_WSAQuerySocketSecurity' -Namespace Win32 -PassThru
# $api::WSAQuerySocketSecurity(Socket, SecurityQueryTemplate, SecurityQueryTemplateLen, SecurityQueryInfo, SecurityQueryInfoLen, Overlapped, CompletionRoutine)#uselib "fwpuclnt.dll"
#func global WSAQuerySocketSecurity "WSAQuerySocketSecurity" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WSAQuerySocketSecurity Socket, varptr(SecurityQueryTemplate), SecurityQueryTemplateLen, varptr(SecurityQueryInfo), varptr(SecurityQueryInfoLen), varptr(Overlapped), CompletionRoutine ; 戻り値は stat
; Socket : SOCKET -> "sptr"
; SecurityQueryTemplate : SOCKET_SECURITY_QUERY_TEMPLATE* optional -> "sptr"
; SecurityQueryTemplateLen : DWORD -> "sptr"
; SecurityQueryInfo : SOCKET_SECURITY_QUERY_INFO* optional, out -> "sptr"
; SecurityQueryInfoLen : DWORD* in/out -> "sptr"
; Overlapped : OVERLAPPED* optional -> "sptr"
; CompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "fwpuclnt.dll" #cfunc global WSAQuerySocketSecurity "WSAQuerySocketSecurity" sptr, var, int, var, var, var, sptr ; res = WSAQuerySocketSecurity(Socket, SecurityQueryTemplate, SecurityQueryTemplateLen, SecurityQueryInfo, SecurityQueryInfoLen, Overlapped, CompletionRoutine) ; Socket : SOCKET -> "sptr" ; SecurityQueryTemplate : SOCKET_SECURITY_QUERY_TEMPLATE* optional -> "var" ; SecurityQueryTemplateLen : DWORD -> "int" ; SecurityQueryInfo : SOCKET_SECURITY_QUERY_INFO* optional, out -> "var" ; SecurityQueryInfoLen : DWORD* in/out -> "var" ; Overlapped : OVERLAPPED* optional -> "var" ; CompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "fwpuclnt.dll" #cfunc global WSAQuerySocketSecurity "WSAQuerySocketSecurity" sptr, sptr, int, sptr, sptr, sptr, sptr ; res = WSAQuerySocketSecurity(Socket, varptr(SecurityQueryTemplate), SecurityQueryTemplateLen, varptr(SecurityQueryInfo), varptr(SecurityQueryInfoLen), varptr(Overlapped), CompletionRoutine) ; Socket : SOCKET -> "sptr" ; SecurityQueryTemplate : SOCKET_SECURITY_QUERY_TEMPLATE* optional -> "sptr" ; SecurityQueryTemplateLen : DWORD -> "int" ; SecurityQueryInfo : SOCKET_SECURITY_QUERY_INFO* optional, out -> "sptr" ; SecurityQueryInfoLen : DWORD* in/out -> "sptr" ; Overlapped : OVERLAPPED* optional -> "sptr" ; CompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT WSAQuerySocketSecurity(SOCKET Socket, SOCKET_SECURITY_QUERY_TEMPLATE* SecurityQueryTemplate, DWORD SecurityQueryTemplateLen, SOCKET_SECURITY_QUERY_INFO* SecurityQueryInfo, DWORD* SecurityQueryInfoLen, OVERLAPPED* Overlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine) #uselib "fwpuclnt.dll" #cfunc global WSAQuerySocketSecurity "WSAQuerySocketSecurity" intptr, var, int, var, var, var, intptr ; res = WSAQuerySocketSecurity(Socket, SecurityQueryTemplate, SecurityQueryTemplateLen, SecurityQueryInfo, SecurityQueryInfoLen, Overlapped, CompletionRoutine) ; Socket : SOCKET -> "intptr" ; SecurityQueryTemplate : SOCKET_SECURITY_QUERY_TEMPLATE* optional -> "var" ; SecurityQueryTemplateLen : DWORD -> "int" ; SecurityQueryInfo : SOCKET_SECURITY_QUERY_INFO* optional, out -> "var" ; SecurityQueryInfoLen : DWORD* in/out -> "var" ; Overlapped : OVERLAPPED* optional -> "var" ; CompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT WSAQuerySocketSecurity(SOCKET Socket, SOCKET_SECURITY_QUERY_TEMPLATE* SecurityQueryTemplate, DWORD SecurityQueryTemplateLen, SOCKET_SECURITY_QUERY_INFO* SecurityQueryInfo, DWORD* SecurityQueryInfoLen, OVERLAPPED* Overlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine) #uselib "fwpuclnt.dll" #cfunc global WSAQuerySocketSecurity "WSAQuerySocketSecurity" intptr, intptr, int, intptr, intptr, intptr, intptr ; res = WSAQuerySocketSecurity(Socket, varptr(SecurityQueryTemplate), SecurityQueryTemplateLen, varptr(SecurityQueryInfo), varptr(SecurityQueryInfoLen), varptr(Overlapped), CompletionRoutine) ; Socket : SOCKET -> "intptr" ; SecurityQueryTemplate : SOCKET_SECURITY_QUERY_TEMPLATE* optional -> "intptr" ; SecurityQueryTemplateLen : DWORD -> "int" ; SecurityQueryInfo : SOCKET_SECURITY_QUERY_INFO* optional, out -> "intptr" ; SecurityQueryInfoLen : DWORD* in/out -> "intptr" ; Overlapped : OVERLAPPED* optional -> "intptr" ; CompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
fwpuclnt = windows.NewLazySystemDLL("fwpuclnt.dll")
procWSAQuerySocketSecurity = fwpuclnt.NewProc("WSAQuerySocketSecurity")
)
// Socket (SOCKET), SecurityQueryTemplate (SOCKET_SECURITY_QUERY_TEMPLATE* optional), SecurityQueryTemplateLen (DWORD), SecurityQueryInfo (SOCKET_SECURITY_QUERY_INFO* optional, out), SecurityQueryInfoLen (DWORD* in/out), Overlapped (OVERLAPPED* optional), CompletionRoutine (LPWSAOVERLAPPED_COMPLETION_ROUTINE optional)
r1, _, err := procWSAQuerySocketSecurity.Call(
uintptr(Socket),
uintptr(SecurityQueryTemplate),
uintptr(SecurityQueryTemplateLen),
uintptr(SecurityQueryInfo),
uintptr(SecurityQueryInfoLen),
uintptr(Overlapped),
uintptr(CompletionRoutine),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction WSAQuerySocketSecurity(
Socket: NativeUInt; // SOCKET
SecurityQueryTemplate: Pointer; // SOCKET_SECURITY_QUERY_TEMPLATE* optional
SecurityQueryTemplateLen: DWORD; // DWORD
SecurityQueryInfo: Pointer; // SOCKET_SECURITY_QUERY_INFO* optional, out
SecurityQueryInfoLen: Pointer; // DWORD* in/out
Overlapped: Pointer; // OVERLAPPED* optional
CompletionRoutine: Pointer // LPWSAOVERLAPPED_COMPLETION_ROUTINE optional
): Integer; stdcall;
external 'fwpuclnt.dll' name 'WSAQuerySocketSecurity';result := DllCall("fwpuclnt\WSAQuerySocketSecurity"
, "UPtr", Socket ; SOCKET
, "Ptr", SecurityQueryTemplate ; SOCKET_SECURITY_QUERY_TEMPLATE* optional
, "UInt", SecurityQueryTemplateLen ; DWORD
, "Ptr", SecurityQueryInfo ; SOCKET_SECURITY_QUERY_INFO* optional, out
, "Ptr", SecurityQueryInfoLen ; DWORD* in/out
, "Ptr", Overlapped ; OVERLAPPED* optional
, "Ptr", CompletionRoutine ; LPWSAOVERLAPPED_COMPLETION_ROUTINE optional
, "Int") ; return: INT●WSAQuerySocketSecurity(Socket, SecurityQueryTemplate, SecurityQueryTemplateLen, SecurityQueryInfo, SecurityQueryInfoLen, Overlapped, CompletionRoutine) = DLL("fwpuclnt.dll", "int WSAQuerySocketSecurity(int, void*, dword, void*, void*, void*, void*)")
# 呼び出し: WSAQuerySocketSecurity(Socket, SecurityQueryTemplate, SecurityQueryTemplateLen, SecurityQueryInfo, SecurityQueryInfoLen, Overlapped, CompletionRoutine)
# Socket : SOCKET -> "int"
# SecurityQueryTemplate : SOCKET_SECURITY_QUERY_TEMPLATE* optional -> "void*"
# SecurityQueryTemplateLen : DWORD -> "dword"
# SecurityQueryInfo : SOCKET_SECURITY_QUERY_INFO* optional, out -> "void*"
# SecurityQueryInfoLen : DWORD* in/out -> "void*"
# Overlapped : OVERLAPPED* optional -> "void*"
# CompletionRoutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。