Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › SecAllocateAndSetIPAddress

SecAllocateAndSetIPAddress

関数
呼び出しコンテキストにIPアドレスを割り当てて設定する。
DLLSspiCli.dll呼出規約winapi

シグネチャ

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

HRESULT SecAllocateAndSetIPAddress(
    BYTE* lpIpAddress,
    DWORD cchIpAddress,
    INT* FreeCallContext
);

パラメーター

名前方向説明
lpIpAddressBYTE*in設定するIPアドレスのバイト列へのポインタ。
cchIpAddressDWORDinlpIpAddressのバイト数を指定する。
FreeCallContextINT*out出力。後で解放するための呼び出しコンテキスト識別子を受け取るポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SecAllocateAndSetIPAddress(
    BYTE* lpIpAddress,
    DWORD cchIpAddress,
    INT* FreeCallContext
);
[DllImport("SspiCli.dll", ExactSpelling = true)]
static extern int SecAllocateAndSetIPAddress(
    IntPtr lpIpAddress,   // BYTE*
    uint cchIpAddress,   // DWORD
    out int FreeCallContext   // INT* out
);
<DllImport("SspiCli.dll", ExactSpelling:=True)>
Public Shared Function SecAllocateAndSetIPAddress(
    lpIpAddress As IntPtr,   ' BYTE*
    cchIpAddress As UInteger,   ' DWORD
    <Out> ByRef FreeCallContext As Integer   ' INT* out
) As Integer
End Function
' lpIpAddress : BYTE*
' cchIpAddress : DWORD
' FreeCallContext : INT* out
Declare PtrSafe Function SecAllocateAndSetIPAddress Lib "sspicli" ( _
    ByVal lpIpAddress As LongPtr, _
    ByVal cchIpAddress As Long, _
    ByRef FreeCallContext As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SecAllocateAndSetIPAddress = ctypes.windll.sspicli.SecAllocateAndSetIPAddress
SecAllocateAndSetIPAddress.restype = ctypes.c_int
SecAllocateAndSetIPAddress.argtypes = [
    ctypes.POINTER(ctypes.c_ubyte),  # lpIpAddress : BYTE*
    wintypes.DWORD,  # cchIpAddress : DWORD
    ctypes.POINTER(ctypes.c_int),  # FreeCallContext : INT* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	sspicli = windows.NewLazySystemDLL("SspiCli.dll")
	procSecAllocateAndSetIPAddress = sspicli.NewProc("SecAllocateAndSetIPAddress")
)

// lpIpAddress (BYTE*), cchIpAddress (DWORD), FreeCallContext (INT* out)
r1, _, err := procSecAllocateAndSetIPAddress.Call(
	uintptr(lpIpAddress),
	uintptr(cchIpAddress),
	uintptr(FreeCallContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SecAllocateAndSetIPAddress(
  lpIpAddress: Pointer;   // BYTE*
  cchIpAddress: DWORD;   // DWORD
  FreeCallContext: Pointer   // INT* out
): Integer; stdcall;
  external 'SspiCli.dll' name 'SecAllocateAndSetIPAddress';
result := DllCall("SspiCli\SecAllocateAndSetIPAddress"
    , "Ptr", lpIpAddress   ; BYTE*
    , "UInt", cchIpAddress   ; DWORD
    , "Ptr", FreeCallContext   ; INT* out
    , "Int")   ; return: HRESULT
●SecAllocateAndSetIPAddress(lpIpAddress, cchIpAddress, FreeCallContext) = DLL("SspiCli.dll", "int SecAllocateAndSetIPAddress(void*, dword, void*)")
# 呼び出し: SecAllocateAndSetIPAddress(lpIpAddress, cchIpAddress, FreeCallContext)
# lpIpAddress : BYTE* -> "void*"
# cchIpAddress : DWORD -> "dword"
# FreeCallContext : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "sspicli" fn SecAllocateAndSetIPAddress(
    lpIpAddress: [*c]u8, // BYTE*
    cchIpAddress: u32, // DWORD
    FreeCallContext: [*c]i32 // INT* out
) callconv(std.os.windows.WINAPI) i32;
proc SecAllocateAndSetIPAddress(
    lpIpAddress: ptr uint8,  # BYTE*
    cchIpAddress: uint32,  # DWORD
    FreeCallContext: ptr int32  # INT* out
): int32 {.importc: "SecAllocateAndSetIPAddress", stdcall, dynlib: "SspiCli.dll".}
pragma(lib, "sspicli");
extern(Windows)
int SecAllocateAndSetIPAddress(
    ubyte* lpIpAddress,   // BYTE*
    uint cchIpAddress,   // DWORD
    int* FreeCallContext   // INT* out
);
ccall((:SecAllocateAndSetIPAddress, "SspiCli.dll"), stdcall, Int32,
      (Ptr{UInt8}, UInt32, Ptr{Int32}),
      lpIpAddress, cchIpAddress, FreeCallContext)
# lpIpAddress : BYTE* -> Ptr{UInt8}
# cchIpAddress : DWORD -> UInt32
# FreeCallContext : INT* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SecAllocateAndSetIPAddress(
    uint8_t* lpIpAddress,
    uint32_t cchIpAddress,
    int32_t* FreeCallContext);
]]
local sspicli = ffi.load("sspicli")
-- sspicli.SecAllocateAndSetIPAddress(lpIpAddress, cchIpAddress, FreeCallContext)
-- lpIpAddress : BYTE*
-- cchIpAddress : DWORD
-- FreeCallContext : INT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SspiCli.dll');
const SecAllocateAndSetIPAddress = lib.func('__stdcall', 'SecAllocateAndSetIPAddress', 'int32_t', ['uint8_t *', 'uint32_t', 'int32_t *']);
// SecAllocateAndSetIPAddress(lpIpAddress, cchIpAddress, FreeCallContext)
// lpIpAddress : BYTE* -> 'uint8_t *'
// cchIpAddress : DWORD -> 'uint32_t'
// FreeCallContext : INT* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SspiCli.dll", {
  SecAllocateAndSetIPAddress: { parameters: ["pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.SecAllocateAndSetIPAddress(lpIpAddress, cchIpAddress, FreeCallContext)
// lpIpAddress : BYTE* -> "pointer"
// cchIpAddress : DWORD -> "u32"
// FreeCallContext : INT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SecAllocateAndSetIPAddress(
    uint8_t* lpIpAddress,
    uint32_t cchIpAddress,
    int32_t* FreeCallContext);
C, "SspiCli.dll");
// $ffi->SecAllocateAndSetIPAddress(lpIpAddress, cchIpAddress, FreeCallContext);
// lpIpAddress : BYTE*
// cchIpAddress : DWORD
// FreeCallContext : INT* 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 Sspicli extends StdCallLibrary {
    Sspicli INSTANCE = Native.load("sspicli", Sspicli.class);
    int SecAllocateAndSetIPAddress(
        byte[] lpIpAddress,   // BYTE*
        int cchIpAddress,   // DWORD
        IntByReference FreeCallContext   // INT* out
    );
}
@[Link("sspicli")]
lib LibSspiCli
  fun SecAllocateAndSetIPAddress = SecAllocateAndSetIPAddress(
    lpIpAddress : UInt8*,   # BYTE*
    cchIpAddress : UInt32,   # DWORD
    FreeCallContext : Int32*   # INT* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SecAllocateAndSetIPAddressNative = Int32 Function(Pointer<Uint8>, Uint32, Pointer<Int32>);
typedef SecAllocateAndSetIPAddressDart = int Function(Pointer<Uint8>, int, Pointer<Int32>);
final SecAllocateAndSetIPAddress = DynamicLibrary.open('SspiCli.dll')
    .lookupFunction<SecAllocateAndSetIPAddressNative, SecAllocateAndSetIPAddressDart>('SecAllocateAndSetIPAddress');
// lpIpAddress : BYTE* -> Pointer<Uint8>
// cchIpAddress : DWORD -> Uint32
// FreeCallContext : INT* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SecAllocateAndSetIPAddress(
  lpIpAddress: Pointer;   // BYTE*
  cchIpAddress: DWORD;   // DWORD
  FreeCallContext: Pointer   // INT* out
): Integer; stdcall;
  external 'SspiCli.dll' name 'SecAllocateAndSetIPAddress';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SecAllocateAndSetIPAddress"
  c_SecAllocateAndSetIPAddress :: Ptr Word8 -> Word32 -> Ptr Int32 -> IO Int32
-- lpIpAddress : BYTE* -> Ptr Word8
-- cchIpAddress : DWORD -> Word32
-- FreeCallContext : INT* out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let secallocateandsetipaddress =
  foreign "SecAllocateAndSetIPAddress"
    ((ptr uint8_t) @-> uint32_t @-> (ptr int32_t) @-> returning int32_t)
(* lpIpAddress : BYTE* -> (ptr uint8_t) *)
(* cchIpAddress : DWORD -> uint32_t *)
(* FreeCallContext : INT* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library sspicli (t "SspiCli.dll"))
(cffi:use-foreign-library sspicli)

(cffi:defcfun ("SecAllocateAndSetIPAddress" sec-allocate-and-set-ipaddress :convention :stdcall) :int32
  (lp-ip-address :pointer)   ; BYTE*
  (cch-ip-address :uint32)   ; DWORD
  (free-call-context :pointer))   ; INT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SecAllocateAndSetIPAddress = Win32::API::More->new('SspiCli',
    'int SecAllocateAndSetIPAddress(LPVOID lpIpAddress, DWORD cchIpAddress, LPVOID FreeCallContext)');
# my $ret = $SecAllocateAndSetIPAddress->Call($lpIpAddress, $cchIpAddress, $FreeCallContext);
# lpIpAddress : BYTE* -> LPVOID
# cchIpAddress : DWORD -> DWORD
# FreeCallContext : INT* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。