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