Win32 API 日本語リファレンス
ホームNetworking.WinSock › WSARevertImpersonation

WSARevertImpersonation

関数
ソケットピアの偽装を解除し元のコンテキストに戻す。
DLLfwpuclnt.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

INT WSARevertImpersonation(void);

パラメーターなし。戻り値: INT

各言語での呼び出し定義

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

INT WSARevertImpersonation(void);
[DllImport("fwpuclnt.dll", SetLastError = true, ExactSpelling = true)]
static extern int WSARevertImpersonation();
<DllImport("fwpuclnt.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WSARevertImpersonation() As Integer
End Function
Declare PtrSafe Function WSARevertImpersonation Lib "fwpuclnt" () As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WSARevertImpersonation = ctypes.windll.fwpuclnt.WSARevertImpersonation
WSARevertImpersonation.restype = ctypes.c_int
WSARevertImpersonation.argtypes = []
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('fwpuclnt.dll')
WSARevertImpersonation = Fiddle::Function.new(
  lib['WSARevertImpersonation'],
  [],
  Fiddle::TYPE_INT)
#[link(name = "fwpuclnt")]
extern "system" {
    fn WSARevertImpersonation() -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("fwpuclnt.dll", SetLastError = true)]
public static extern int WSARevertImpersonation();
"@
$api = Add-Type -MemberDefinition $sig -Name 'fwpuclnt_WSARevertImpersonation' -Namespace Win32 -PassThru
# $api::WSARevertImpersonation()
#uselib "fwpuclnt.dll"
#func global WSARevertImpersonation "WSARevertImpersonation"
; WSARevertImpersonation   ; 戻り値は stat
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "fwpuclnt.dll"
#cfunc global WSARevertImpersonation "WSARevertImpersonation"
; res = WSARevertImpersonation()
; INT WSARevertImpersonation()
#uselib "fwpuclnt.dll"
#cfunc global WSARevertImpersonation "WSARevertImpersonation"
; res = WSARevertImpersonation()
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	fwpuclnt = windows.NewLazySystemDLL("fwpuclnt.dll")
	procWSARevertImpersonation = fwpuclnt.NewProc("WSARevertImpersonation")
)

r1, _, err := procWSARevertImpersonation.Call()
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function WSARevertImpersonation: Integer; stdcall;
  external 'fwpuclnt.dll' name 'WSARevertImpersonation';
result := DllCall("fwpuclnt\WSARevertImpersonation", "Int")
●WSARevertImpersonation() = DLL("fwpuclnt.dll", "int WSARevertImpersonation()")
# 呼び出し: WSARevertImpersonation()
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。