Win32 API 日本語リファレンス
ホームSystem.DeploymentServices › PxeDhcpv6AppendOptionRaw

PxeDhcpv6AppendOptionRaw

関数
DHCPv6応答パケットに生バイト列のオプションを追加する。
DLLWDSPXE.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD PxeDhcpv6AppendOptionRaw(
    void* pReply,
    DWORD cbReply,
    DWORD* pcbReplyUsed,
    WORD cbBuffer,
    void* pBuffer
);

パラメーター

名前方向説明
pReplyvoid*inout生バイト列を追記する対象のDHCPv6応答パケットバッファ。
cbReplyDWORDin応答バッファの最大サイズ(バイト単位)。
pcbReplyUsedDWORD*inout現在の応答長を入力し追記後の長さを受け取るDWORDポインタ。
cbBufferWORDin追記する生バッファの長さ(バイト単位)。
pBuffervoid*inそのまま追記するオプションの生バイト列へのポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD PxeDhcpv6AppendOptionRaw(
    void* pReply,
    DWORD cbReply,
    DWORD* pcbReplyUsed,
    WORD cbBuffer,
    void* pBuffer
);
[DllImport("WDSPXE.dll", ExactSpelling = true)]
static extern uint PxeDhcpv6AppendOptionRaw(
    IntPtr pReply,   // void* in/out
    uint cbReply,   // DWORD
    ref uint pcbReplyUsed,   // DWORD* in/out
    ushort cbBuffer,   // WORD
    IntPtr pBuffer   // void*
);
<DllImport("WDSPXE.dll", ExactSpelling:=True)>
Public Shared Function PxeDhcpv6AppendOptionRaw(
    pReply As IntPtr,   ' void* in/out
    cbReply As UInteger,   ' DWORD
    ByRef pcbReplyUsed As UInteger,   ' DWORD* in/out
    cbBuffer As UShort,   ' WORD
    pBuffer As IntPtr   ' void*
) As UInteger
End Function
' pReply : void* in/out
' cbReply : DWORD
' pcbReplyUsed : DWORD* in/out
' cbBuffer : WORD
' pBuffer : void*
Declare PtrSafe Function PxeDhcpv6AppendOptionRaw Lib "wdspxe" ( _
    ByVal pReply As LongPtr, _
    ByVal cbReply As Long, _
    ByRef pcbReplyUsed As Long, _
    ByVal cbBuffer As Integer, _
    ByVal pBuffer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PxeDhcpv6AppendOptionRaw = ctypes.windll.wdspxe.PxeDhcpv6AppendOptionRaw
PxeDhcpv6AppendOptionRaw.restype = wintypes.DWORD
PxeDhcpv6AppendOptionRaw.argtypes = [
    ctypes.POINTER(None),  # pReply : void* in/out
    wintypes.DWORD,  # cbReply : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pcbReplyUsed : DWORD* in/out
    ctypes.c_ushort,  # cbBuffer : WORD
    ctypes.POINTER(None),  # pBuffer : void*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wdspxe = windows.NewLazySystemDLL("WDSPXE.dll")
	procPxeDhcpv6AppendOptionRaw = wdspxe.NewProc("PxeDhcpv6AppendOptionRaw")
)

// pReply (void* in/out), cbReply (DWORD), pcbReplyUsed (DWORD* in/out), cbBuffer (WORD), pBuffer (void*)
r1, _, err := procPxeDhcpv6AppendOptionRaw.Call(
	uintptr(pReply),
	uintptr(cbReply),
	uintptr(pcbReplyUsed),
	uintptr(cbBuffer),
	uintptr(pBuffer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PxeDhcpv6AppendOptionRaw(
  pReply: Pointer;   // void* in/out
  cbReply: DWORD;   // DWORD
  pcbReplyUsed: Pointer;   // DWORD* in/out
  cbBuffer: Word;   // WORD
  pBuffer: Pointer   // void*
): DWORD; stdcall;
  external 'WDSPXE.dll' name 'PxeDhcpv6AppendOptionRaw';
result := DllCall("WDSPXE\PxeDhcpv6AppendOptionRaw"
    , "Ptr", pReply   ; void* in/out
    , "UInt", cbReply   ; DWORD
    , "Ptr", pcbReplyUsed   ; DWORD* in/out
    , "UShort", cbBuffer   ; WORD
    , "Ptr", pBuffer   ; void*
    , "UInt")   ; return: DWORD
●PxeDhcpv6AppendOptionRaw(pReply, cbReply, pcbReplyUsed, cbBuffer, pBuffer) = DLL("WDSPXE.dll", "dword PxeDhcpv6AppendOptionRaw(void*, dword, void*, int, void*)")
# 呼び出し: PxeDhcpv6AppendOptionRaw(pReply, cbReply, pcbReplyUsed, cbBuffer, pBuffer)
# pReply : void* in/out -> "void*"
# cbReply : DWORD -> "dword"
# pcbReplyUsed : DWORD* in/out -> "void*"
# cbBuffer : WORD -> "int"
# pBuffer : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef PxeDhcpv6AppendOptionRawNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Uint32>, Uint16, Pointer<Void>);
typedef PxeDhcpv6AppendOptionRawDart = int Function(Pointer<Void>, int, Pointer<Uint32>, int, Pointer<Void>);
final PxeDhcpv6AppendOptionRaw = DynamicLibrary.open('WDSPXE.dll')
    .lookupFunction<PxeDhcpv6AppendOptionRawNative, PxeDhcpv6AppendOptionRawDart>('PxeDhcpv6AppendOptionRaw');
// pReply : void* in/out -> Pointer<Void>
// cbReply : DWORD -> Uint32
// pcbReplyUsed : DWORD* in/out -> Pointer<Uint32>
// cbBuffer : WORD -> Uint16
// pBuffer : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PxeDhcpv6AppendOptionRaw(
  pReply: Pointer;   // void* in/out
  cbReply: DWORD;   // DWORD
  pcbReplyUsed: Pointer;   // DWORD* in/out
  cbBuffer: Word;   // WORD
  pBuffer: Pointer   // void*
): DWORD; stdcall;
  external 'WDSPXE.dll' name 'PxeDhcpv6AppendOptionRaw';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PxeDhcpv6AppendOptionRaw"
  c_PxeDhcpv6AppendOptionRaw :: Ptr () -> Word32 -> Ptr Word32 -> Word16 -> Ptr () -> IO Word32
-- pReply : void* in/out -> Ptr ()
-- cbReply : DWORD -> Word32
-- pcbReplyUsed : DWORD* in/out -> Ptr Word32
-- cbBuffer : WORD -> Word16
-- pBuffer : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let pxedhcpv6appendoptionraw =
  foreign "PxeDhcpv6AppendOptionRaw"
    ((ptr void) @-> uint32_t @-> (ptr uint32_t) @-> uint16_t @-> (ptr void) @-> returning uint32_t)
(* pReply : void* in/out -> (ptr void) *)
(* cbReply : DWORD -> uint32_t *)
(* pcbReplyUsed : DWORD* in/out -> (ptr uint32_t) *)
(* cbBuffer : WORD -> uint16_t *)
(* pBuffer : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wdspxe (t "WDSPXE.dll"))
(cffi:use-foreign-library wdspxe)

(cffi:defcfun ("PxeDhcpv6AppendOptionRaw" pxe-dhcpv6-append-option-raw :convention :stdcall) :uint32
  (p-reply :pointer)   ; void* in/out
  (cb-reply :uint32)   ; DWORD
  (pcb-reply-used :pointer)   ; DWORD* in/out
  (cb-buffer :uint16)   ; WORD
  (p-buffer :pointer))   ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PxeDhcpv6AppendOptionRaw = Win32::API::More->new('WDSPXE',
    'DWORD PxeDhcpv6AppendOptionRaw(LPVOID pReply, DWORD cbReply, LPVOID pcbReplyUsed, WORD cbBuffer, LPVOID pBuffer)');
# my $ret = $PxeDhcpv6AppendOptionRaw->Call($pReply, $cbReply, $pcbReplyUsed, $cbBuffer, $pBuffer);
# pReply : void* in/out -> LPVOID
# cbReply : DWORD -> DWORD
# pcbReplyUsed : DWORD* in/out -> LPVOID
# cbBuffer : WORD -> WORD
# pBuffer : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。