ホーム › System.DeploymentServices › PxeDhcpAppendOptionRaw
PxeDhcpAppendOptionRaw
関数DHCP応答パケットに生バイト列のオプションを追加する。
シグネチャ
// WDSPXE.dll
#include <windows.h>
DWORD PxeDhcpAppendOptionRaw(
void* pReplyPacket,
DWORD uMaxReplyPacketLen,
DWORD* puReplyPacketLen,
WORD uBufferLen,
void* pBuffer
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pReplyPacket | void* | inout | 生バイト列を追記する対象のDHCP応答パケットバッファ。 |
| uMaxReplyPacketLen | DWORD | in | 応答バッファの最大サイズ(バイト単位)。 |
| puReplyPacketLen | DWORD* | inout | 現在の応答長を入力し追記後の長さを受け取るDWORDポインタ。 |
| uBufferLen | WORD | in | 追記する生バッファの長さ(バイト単位)。 |
| pBuffer | void* | in | そのまま追記するオプションの生バイト列へのポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// WDSPXE.dll
#include <windows.h>
DWORD PxeDhcpAppendOptionRaw(
void* pReplyPacket,
DWORD uMaxReplyPacketLen,
DWORD* puReplyPacketLen,
WORD uBufferLen,
void* pBuffer
);[DllImport("WDSPXE.dll", ExactSpelling = true)]
static extern uint PxeDhcpAppendOptionRaw(
IntPtr pReplyPacket, // void* in/out
uint uMaxReplyPacketLen, // DWORD
ref uint puReplyPacketLen, // DWORD* in/out
ushort uBufferLen, // WORD
IntPtr pBuffer // void*
);<DllImport("WDSPXE.dll", ExactSpelling:=True)>
Public Shared Function PxeDhcpAppendOptionRaw(
pReplyPacket As IntPtr, ' void* in/out
uMaxReplyPacketLen As UInteger, ' DWORD
ByRef puReplyPacketLen As UInteger, ' DWORD* in/out
uBufferLen As UShort, ' WORD
pBuffer As IntPtr ' void*
) As UInteger
End Function' pReplyPacket : void* in/out
' uMaxReplyPacketLen : DWORD
' puReplyPacketLen : DWORD* in/out
' uBufferLen : WORD
' pBuffer : void*
Declare PtrSafe Function PxeDhcpAppendOptionRaw Lib "wdspxe" ( _
ByVal pReplyPacket As LongPtr, _
ByVal uMaxReplyPacketLen As Long, _
ByRef puReplyPacketLen As Long, _
ByVal uBufferLen 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
PxeDhcpAppendOptionRaw = ctypes.windll.wdspxe.PxeDhcpAppendOptionRaw
PxeDhcpAppendOptionRaw.restype = wintypes.DWORD
PxeDhcpAppendOptionRaw.argtypes = [
ctypes.POINTER(None), # pReplyPacket : void* in/out
wintypes.DWORD, # uMaxReplyPacketLen : DWORD
ctypes.POINTER(wintypes.DWORD), # puReplyPacketLen : DWORD* in/out
ctypes.c_ushort, # uBufferLen : WORD
ctypes.POINTER(None), # pBuffer : void*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WDSPXE.dll')
PxeDhcpAppendOptionRaw = Fiddle::Function.new(
lib['PxeDhcpAppendOptionRaw'],
[
Fiddle::TYPE_VOIDP, # pReplyPacket : void* in/out
-Fiddle::TYPE_INT, # uMaxReplyPacketLen : DWORD
Fiddle::TYPE_VOIDP, # puReplyPacketLen : DWORD* in/out
-Fiddle::TYPE_SHORT, # uBufferLen : WORD
Fiddle::TYPE_VOIDP, # pBuffer : void*
],
-Fiddle::TYPE_INT)#[link(name = "wdspxe")]
extern "system" {
fn PxeDhcpAppendOptionRaw(
pReplyPacket: *mut (), // void* in/out
uMaxReplyPacketLen: u32, // DWORD
puReplyPacketLen: *mut u32, // DWORD* in/out
uBufferLen: u16, // WORD
pBuffer: *mut () // void*
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WDSPXE.dll")]
public static extern uint PxeDhcpAppendOptionRaw(IntPtr pReplyPacket, uint uMaxReplyPacketLen, ref uint puReplyPacketLen, ushort uBufferLen, IntPtr pBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WDSPXE_PxeDhcpAppendOptionRaw' -Namespace Win32 -PassThru
# $api::PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, uBufferLen, pBuffer)#uselib "WDSPXE.dll"
#func global PxeDhcpAppendOptionRaw "PxeDhcpAppendOptionRaw" sptr, sptr, sptr, sptr, sptr
; PxeDhcpAppendOptionRaw pReplyPacket, uMaxReplyPacketLen, varptr(puReplyPacketLen), uBufferLen, pBuffer ; 戻り値は stat
; pReplyPacket : void* in/out -> "sptr"
; uMaxReplyPacketLen : DWORD -> "sptr"
; puReplyPacketLen : DWORD* in/out -> "sptr"
; uBufferLen : WORD -> "sptr"
; pBuffer : void* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WDSPXE.dll" #cfunc global PxeDhcpAppendOptionRaw "PxeDhcpAppendOptionRaw" sptr, int, var, int, sptr ; res = PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, uBufferLen, pBuffer) ; pReplyPacket : void* in/out -> "sptr" ; uMaxReplyPacketLen : DWORD -> "int" ; puReplyPacketLen : DWORD* in/out -> "var" ; uBufferLen : WORD -> "int" ; pBuffer : void* -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WDSPXE.dll" #cfunc global PxeDhcpAppendOptionRaw "PxeDhcpAppendOptionRaw" sptr, int, sptr, int, sptr ; res = PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, varptr(puReplyPacketLen), uBufferLen, pBuffer) ; pReplyPacket : void* in/out -> "sptr" ; uMaxReplyPacketLen : DWORD -> "int" ; puReplyPacketLen : DWORD* in/out -> "sptr" ; uBufferLen : WORD -> "int" ; pBuffer : void* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD PxeDhcpAppendOptionRaw(void* pReplyPacket, DWORD uMaxReplyPacketLen, DWORD* puReplyPacketLen, WORD uBufferLen, void* pBuffer) #uselib "WDSPXE.dll" #cfunc global PxeDhcpAppendOptionRaw "PxeDhcpAppendOptionRaw" intptr, int, var, int, intptr ; res = PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, uBufferLen, pBuffer) ; pReplyPacket : void* in/out -> "intptr" ; uMaxReplyPacketLen : DWORD -> "int" ; puReplyPacketLen : DWORD* in/out -> "var" ; uBufferLen : WORD -> "int" ; pBuffer : void* -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD PxeDhcpAppendOptionRaw(void* pReplyPacket, DWORD uMaxReplyPacketLen, DWORD* puReplyPacketLen, WORD uBufferLen, void* pBuffer) #uselib "WDSPXE.dll" #cfunc global PxeDhcpAppendOptionRaw "PxeDhcpAppendOptionRaw" intptr, int, intptr, int, intptr ; res = PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, varptr(puReplyPacketLen), uBufferLen, pBuffer) ; pReplyPacket : void* in/out -> "intptr" ; uMaxReplyPacketLen : DWORD -> "int" ; puReplyPacketLen : DWORD* in/out -> "intptr" ; uBufferLen : WORD -> "int" ; pBuffer : void* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wdspxe = windows.NewLazySystemDLL("WDSPXE.dll")
procPxeDhcpAppendOptionRaw = wdspxe.NewProc("PxeDhcpAppendOptionRaw")
)
// pReplyPacket (void* in/out), uMaxReplyPacketLen (DWORD), puReplyPacketLen (DWORD* in/out), uBufferLen (WORD), pBuffer (void*)
r1, _, err := procPxeDhcpAppendOptionRaw.Call(
uintptr(pReplyPacket),
uintptr(uMaxReplyPacketLen),
uintptr(puReplyPacketLen),
uintptr(uBufferLen),
uintptr(pBuffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PxeDhcpAppendOptionRaw(
pReplyPacket: Pointer; // void* in/out
uMaxReplyPacketLen: DWORD; // DWORD
puReplyPacketLen: Pointer; // DWORD* in/out
uBufferLen: Word; // WORD
pBuffer: Pointer // void*
): DWORD; stdcall;
external 'WDSPXE.dll' name 'PxeDhcpAppendOptionRaw';result := DllCall("WDSPXE\PxeDhcpAppendOptionRaw"
, "Ptr", pReplyPacket ; void* in/out
, "UInt", uMaxReplyPacketLen ; DWORD
, "Ptr", puReplyPacketLen ; DWORD* in/out
, "UShort", uBufferLen ; WORD
, "Ptr", pBuffer ; void*
, "UInt") ; return: DWORD●PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, uBufferLen, pBuffer) = DLL("WDSPXE.dll", "dword PxeDhcpAppendOptionRaw(void*, dword, void*, int, void*)")
# 呼び出し: PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, uBufferLen, pBuffer)
# pReplyPacket : void* in/out -> "void*"
# uMaxReplyPacketLen : DWORD -> "dword"
# puReplyPacketLen : DWORD* in/out -> "void*"
# uBufferLen : WORD -> "int"
# pBuffer : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wdspxe" fn PxeDhcpAppendOptionRaw(
pReplyPacket: ?*anyopaque, // void* in/out
uMaxReplyPacketLen: u32, // DWORD
puReplyPacketLen: [*c]u32, // DWORD* in/out
uBufferLen: u16, // WORD
pBuffer: ?*anyopaque // void*
) callconv(std.os.windows.WINAPI) u32;proc PxeDhcpAppendOptionRaw(
pReplyPacket: pointer, # void* in/out
uMaxReplyPacketLen: uint32, # DWORD
puReplyPacketLen: ptr uint32, # DWORD* in/out
uBufferLen: uint16, # WORD
pBuffer: pointer # void*
): uint32 {.importc: "PxeDhcpAppendOptionRaw", stdcall, dynlib: "WDSPXE.dll".}pragma(lib, "wdspxe");
extern(Windows)
uint PxeDhcpAppendOptionRaw(
void* pReplyPacket, // void* in/out
uint uMaxReplyPacketLen, // DWORD
uint* puReplyPacketLen, // DWORD* in/out
ushort uBufferLen, // WORD
void* pBuffer // void*
);ccall((:PxeDhcpAppendOptionRaw, "WDSPXE.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32, Ptr{UInt32}, UInt16, Ptr{Cvoid}),
pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, uBufferLen, pBuffer)
# pReplyPacket : void* in/out -> Ptr{Cvoid}
# uMaxReplyPacketLen : DWORD -> UInt32
# puReplyPacketLen : DWORD* in/out -> Ptr{UInt32}
# uBufferLen : WORD -> UInt16
# pBuffer : void* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t PxeDhcpAppendOptionRaw(
void* pReplyPacket,
uint32_t uMaxReplyPacketLen,
uint32_t* puReplyPacketLen,
uint16_t uBufferLen,
void* pBuffer);
]]
local wdspxe = ffi.load("wdspxe")
-- wdspxe.PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, uBufferLen, pBuffer)
-- pReplyPacket : void* in/out
-- uMaxReplyPacketLen : DWORD
-- puReplyPacketLen : DWORD* in/out
-- uBufferLen : WORD
-- pBuffer : void*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WDSPXE.dll');
const PxeDhcpAppendOptionRaw = lib.func('__stdcall', 'PxeDhcpAppendOptionRaw', 'uint32_t', ['void *', 'uint32_t', 'uint32_t *', 'uint16_t', 'void *']);
// PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, uBufferLen, pBuffer)
// pReplyPacket : void* in/out -> 'void *'
// uMaxReplyPacketLen : DWORD -> 'uint32_t'
// puReplyPacketLen : DWORD* in/out -> 'uint32_t *'
// uBufferLen : WORD -> 'uint16_t'
// pBuffer : void* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WDSPXE.dll", {
PxeDhcpAppendOptionRaw: { parameters: ["pointer", "u32", "pointer", "u16", "pointer"], result: "u32" },
});
// lib.symbols.PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, uBufferLen, pBuffer)
// pReplyPacket : void* in/out -> "pointer"
// uMaxReplyPacketLen : DWORD -> "u32"
// puReplyPacketLen : DWORD* in/out -> "pointer"
// uBufferLen : WORD -> "u16"
// pBuffer : void* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t PxeDhcpAppendOptionRaw(
void* pReplyPacket,
uint32_t uMaxReplyPacketLen,
uint32_t* puReplyPacketLen,
uint16_t uBufferLen,
void* pBuffer);
C, "WDSPXE.dll");
// $ffi->PxeDhcpAppendOptionRaw(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, uBufferLen, pBuffer);
// pReplyPacket : void* in/out
// uMaxReplyPacketLen : DWORD
// puReplyPacketLen : DWORD* in/out
// uBufferLen : 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 PxeDhcpAppendOptionRaw(
Pointer pReplyPacket, // void* in/out
int uMaxReplyPacketLen, // DWORD
IntByReference puReplyPacketLen, // DWORD* in/out
short uBufferLen, // WORD
Pointer pBuffer // void*
);
}@[Link("wdspxe")]
lib LibWDSPXE
fun PxeDhcpAppendOptionRaw = PxeDhcpAppendOptionRaw(
pReplyPacket : Void*, # void* in/out
uMaxReplyPacketLen : UInt32, # DWORD
puReplyPacketLen : UInt32*, # DWORD* in/out
uBufferLen : 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 PxeDhcpAppendOptionRawNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Uint32>, Uint16, Pointer<Void>);
typedef PxeDhcpAppendOptionRawDart = int Function(Pointer<Void>, int, Pointer<Uint32>, int, Pointer<Void>);
final PxeDhcpAppendOptionRaw = DynamicLibrary.open('WDSPXE.dll')
.lookupFunction<PxeDhcpAppendOptionRawNative, PxeDhcpAppendOptionRawDart>('PxeDhcpAppendOptionRaw');
// pReplyPacket : void* in/out -> Pointer<Void>
// uMaxReplyPacketLen : DWORD -> Uint32
// puReplyPacketLen : DWORD* in/out -> Pointer<Uint32>
// uBufferLen : WORD -> Uint16
// pBuffer : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PxeDhcpAppendOptionRaw(
pReplyPacket: Pointer; // void* in/out
uMaxReplyPacketLen: DWORD; // DWORD
puReplyPacketLen: Pointer; // DWORD* in/out
uBufferLen: Word; // WORD
pBuffer: Pointer // void*
): DWORD; stdcall;
external 'WDSPXE.dll' name 'PxeDhcpAppendOptionRaw';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PxeDhcpAppendOptionRaw"
c_PxeDhcpAppendOptionRaw :: Ptr () -> Word32 -> Ptr Word32 -> Word16 -> Ptr () -> IO Word32
-- pReplyPacket : void* in/out -> Ptr ()
-- uMaxReplyPacketLen : DWORD -> Word32
-- puReplyPacketLen : DWORD* in/out -> Ptr Word32
-- uBufferLen : WORD -> Word16
-- pBuffer : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let pxedhcpappendoptionraw =
foreign "PxeDhcpAppendOptionRaw"
((ptr void) @-> uint32_t @-> (ptr uint32_t) @-> uint16_t @-> (ptr void) @-> returning uint32_t)
(* pReplyPacket : void* in/out -> (ptr void) *)
(* uMaxReplyPacketLen : DWORD -> uint32_t *)
(* puReplyPacketLen : DWORD* in/out -> (ptr uint32_t) *)
(* uBufferLen : 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 ("PxeDhcpAppendOptionRaw" pxe-dhcp-append-option-raw :convention :stdcall) :uint32
(p-reply-packet :pointer) ; void* in/out
(u-max-reply-packet-len :uint32) ; DWORD
(pu-reply-packet-len :pointer) ; DWORD* in/out
(u-buffer-len :uint16) ; WORD
(p-buffer :pointer)) ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PxeDhcpAppendOptionRaw = Win32::API::More->new('WDSPXE',
'DWORD PxeDhcpAppendOptionRaw(LPVOID pReplyPacket, DWORD uMaxReplyPacketLen, LPVOID puReplyPacketLen, WORD uBufferLen, LPVOID pBuffer)');
# my $ret = $PxeDhcpAppendOptionRaw->Call($pReplyPacket, $uMaxReplyPacketLen, $puReplyPacketLen, $uBufferLen, $pBuffer);
# pReplyPacket : void* in/out -> LPVOID
# uMaxReplyPacketLen : DWORD -> DWORD
# puReplyPacketLen : DWORD* in/out -> LPVOID
# uBufferLen : WORD -> WORD
# pBuffer : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。