Win32 API 日本語リファレンス
ホームNetworkManagement.Dns › DNS_QUERY_RAW_REQUEST

DNS_QUERY_RAW_REQUEST

構造体
サイズx64: 136 バイト / x86: 104 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
versionDWORD4+0+0リクエスト構造体のバージョン番号を示す。
resultsVersionDWORD4+4+4期待する結果構造体のバージョン番号を示す。
dnsQueryRawSizeDWORD4+8+8dnsQueryRawが指す生クエリのバイト長を示す。
dnsQueryRawBYTE*8/4+16+12送信する生(ワイヤ形式)クエリバイト列を指すポインタ。NULLで名前指定。
dnsQueryNameLPWSTR8/4+24+16問い合わせるドメイン名を表すワイド文字列ポインタ。
dnsQueryTypeWORD2+32+20問い合わせるレコード種別を示すDNSタイプ値。
queryOptionsULONGLONG8+40+24解決動作を制御するDNS_QUERY_OPTIONSフラグを保持する。
interfaceIndexDWORD4+48+32問い合わせに使用するネットワークインターフェースのインデックス。0で自動選択。
queryCompletionCallbackDNS_QUERY_RAW_COMPLETION_ROUTINE8/4+56+36非同期完了時に呼ばれるRAWクエリ完了コールバック関数。
queryContextvoid*8/4+64+40コールバックに渡されるユーザ定義コンテキストポインタ。NULL可。
queryRawOptionsULONGLONG8+72+48RAWクエリ固有のオプションフラグを保持する。
customServersSizeDWORD4+80+56customServersが指すカスタムサーバ要素数を示す。
customServersDNS_CUSTOM_SERVER*8/4+88+60使用するカスタムDNSサーバ配列を指すポインタ。NULL可。
protocolDWORD4+96+64問い合わせに使用する転送プロトコルを示す。
Anonymous_Anonymous_e__Union32+100+68プロトコル固有の付加設定を保持する無名共用体。

共用体: _Anonymous_e__Union x64 32B / x86 32B

フィールドサイズx64x86
maxSaCHAR32+0+0

各言語での定義

#include <windows.h>

// DNS_QUERY_RAW_REQUEST  (x64 136 / x86 104 バイト)
typedef struct DNS_QUERY_RAW_REQUEST {
    DWORD version;
    DWORD resultsVersion;
    DWORD dnsQueryRawSize;
    BYTE* dnsQueryRaw;
    LPWSTR dnsQueryName;
    WORD dnsQueryType;
    ULONGLONG queryOptions;
    DWORD interfaceIndex;
    DNS_QUERY_RAW_COMPLETION_ROUTINE queryCompletionCallback;
    void* queryContext;
    ULONGLONG queryRawOptions;
    DWORD customServersSize;
    DNS_CUSTOM_SERVER* customServers;
    DWORD protocol;
    _Anonymous_e__Union Anonymous;
} DNS_QUERY_RAW_REQUEST;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DNS_QUERY_RAW_REQUEST
{
    public uint version;
    public uint resultsVersion;
    public uint dnsQueryRawSize;
    public IntPtr dnsQueryRaw;
    public IntPtr dnsQueryName;
    public ushort dnsQueryType;
    public ulong queryOptions;
    public uint interfaceIndex;
    public IntPtr queryCompletionCallback;
    public IntPtr queryContext;
    public ulong queryRawOptions;
    public uint customServersSize;
    public IntPtr customServers;
    public uint protocol;
    public _Anonymous_e__Union Anonymous;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DNS_QUERY_RAW_REQUEST
    Public version As UInteger
    Public resultsVersion As UInteger
    Public dnsQueryRawSize As UInteger
    Public dnsQueryRaw As IntPtr
    Public dnsQueryName As IntPtr
    Public dnsQueryType As UShort
    Public queryOptions As ULong
    Public interfaceIndex As UInteger
    Public queryCompletionCallback As IntPtr
    Public queryContext As IntPtr
    Public queryRawOptions As ULong
    Public customServersSize As UInteger
    Public customServers As IntPtr
    Public protocol As UInteger
    Public Anonymous As _Anonymous_e__Union
End Structure
import ctypes
from ctypes import wintypes

class DNS_QUERY_RAW_REQUEST(ctypes.Structure):
    _fields_ = [
        ("version", wintypes.DWORD),
        ("resultsVersion", wintypes.DWORD),
        ("dnsQueryRawSize", wintypes.DWORD),
        ("dnsQueryRaw", ctypes.c_void_p),
        ("dnsQueryName", ctypes.c_void_p),
        ("dnsQueryType", ctypes.c_ushort),
        ("queryOptions", ctypes.c_ulonglong),
        ("interfaceIndex", wintypes.DWORD),
        ("queryCompletionCallback", ctypes.c_void_p),
        ("queryContext", ctypes.c_void_p),
        ("queryRawOptions", ctypes.c_ulonglong),
        ("customServersSize", wintypes.DWORD),
        ("customServers", ctypes.c_void_p),
        ("protocol", wintypes.DWORD),
        ("Anonymous", _Anonymous_e__Union),
    ]
#[repr(C)]
pub struct DNS_QUERY_RAW_REQUEST {
    pub version: u32,
    pub resultsVersion: u32,
    pub dnsQueryRawSize: u32,
    pub dnsQueryRaw: *mut core::ffi::c_void,
    pub dnsQueryName: *mut core::ffi::c_void,
    pub dnsQueryType: u16,
    pub queryOptions: u64,
    pub interfaceIndex: u32,
    pub queryCompletionCallback: *mut core::ffi::c_void,
    pub queryContext: *mut core::ffi::c_void,
    pub queryRawOptions: u64,
    pub customServersSize: u32,
    pub customServers: *mut core::ffi::c_void,
    pub protocol: u32,
    pub Anonymous: _Anonymous_e__Union,
}
import "golang.org/x/sys/windows"

type DNS_QUERY_RAW_REQUEST struct {
	version uint32
	resultsVersion uint32
	dnsQueryRawSize uint32
	dnsQueryRaw uintptr
	dnsQueryName uintptr
	dnsQueryType uint16
	queryOptions uint64
	interfaceIndex uint32
	queryCompletionCallback uintptr
	queryContext uintptr
	queryRawOptions uint64
	customServersSize uint32
	customServers uintptr
	protocol uint32
	Anonymous _Anonymous_e__Union
}
type
  DNS_QUERY_RAW_REQUEST = record
    version: DWORD;
    resultsVersion: DWORD;
    dnsQueryRawSize: DWORD;
    dnsQueryRaw: Pointer;
    dnsQueryName: Pointer;
    dnsQueryType: Word;
    queryOptions: UInt64;
    interfaceIndex: DWORD;
    queryCompletionCallback: Pointer;
    queryContext: Pointer;
    queryRawOptions: UInt64;
    customServersSize: DWORD;
    customServers: Pointer;
    protocol: DWORD;
    Anonymous: _Anonymous_e__Union;
  end;
const DNS_QUERY_RAW_REQUEST = extern struct {
    version: u32,
    resultsVersion: u32,
    dnsQueryRawSize: u32,
    dnsQueryRaw: ?*anyopaque,
    dnsQueryName: ?*anyopaque,
    dnsQueryType: u16,
    queryOptions: u64,
    interfaceIndex: u32,
    queryCompletionCallback: ?*anyopaque,
    queryContext: ?*anyopaque,
    queryRawOptions: u64,
    customServersSize: u32,
    customServers: ?*anyopaque,
    protocol: u32,
    Anonymous: _Anonymous_e__Union,
};
type
  DNS_QUERY_RAW_REQUEST {.bycopy.} = object
    version: uint32
    resultsVersion: uint32
    dnsQueryRawSize: uint32
    dnsQueryRaw: pointer
    dnsQueryName: pointer
    dnsQueryType: uint16
    queryOptions: uint64
    interfaceIndex: uint32
    queryCompletionCallback: pointer
    queryContext: pointer
    queryRawOptions: uint64
    customServersSize: uint32
    customServers: pointer
    protocol: uint32
    Anonymous: _Anonymous_e__Union
struct DNS_QUERY_RAW_REQUEST
{
    uint version;
    uint resultsVersion;
    uint dnsQueryRawSize;
    void* dnsQueryRaw;
    void* dnsQueryName;
    ushort dnsQueryType;
    ulong queryOptions;
    uint interfaceIndex;
    void* queryCompletionCallback;
    void* queryContext;
    ulong queryRawOptions;
    uint customServersSize;
    void* customServers;
    uint protocol;
    _Anonymous_e__Union Anonymous;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DNS_QUERY_RAW_REQUEST サイズ: 104 バイト(x86)
dim st, 26    ; 4byte整数×26(構造体サイズ 104 / 4 切り上げ)
; version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; resultsVersion : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dnsQueryRawSize : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; dnsQueryRaw : BYTE* (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dnsQueryName : LPWSTR (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; dnsQueryType : WORD (+20, 2byte)  wpoke st,20,値  /  値 = wpeek(st,20)
; queryOptions : ULONGLONG (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; interfaceIndex : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; queryCompletionCallback : DNS_QUERY_RAW_COMPLETION_ROUTINE (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; queryContext : void* (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; queryRawOptions : ULONGLONG (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; customServersSize : DWORD (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; customServers : DNS_CUSTOM_SERVER* (+60, 4byte)  varptr(st)+60 を基点に操作(4byte:入れ子/配列)
; protocol : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+68, 32byte)  varptr(st)+68 を基点に操作(32byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DNS_QUERY_RAW_REQUEST サイズ: 136 バイト(x64)
dim st, 34    ; 4byte整数×34(構造体サイズ 136 / 4 切り上げ)
; version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; resultsVersion : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dnsQueryRawSize : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; dnsQueryRaw : BYTE* (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; dnsQueryName : LPWSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; dnsQueryType : WORD (+32, 2byte)  wpoke st,32,値  /  値 = wpeek(st,32)
; queryOptions : ULONGLONG (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; interfaceIndex : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; queryCompletionCallback : DNS_QUERY_RAW_COMPLETION_ROUTINE (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; queryContext : void* (+64, 8byte)  qpoke st,64,値 / qpeek(st,64)  ※IronHSPのみ。3.7/3.8は lpoke st,64,下位 : lpoke st,68,上位
; queryRawOptions : ULONGLONG (+72, 8byte)  qpoke st,72,値 / qpeek(st,72)  ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; customServersSize : DWORD (+80, 4byte)  st.20 = 値  /  値 = st.20   (lpoke/lpeek も可)
; customServers : DNS_CUSTOM_SERVER* (+88, 8byte)  varptr(st)+88 を基点に操作(8byte:入れ子/配列)
; protocol : DWORD (+96, 4byte)  st.24 = 値  /  値 = st.24   (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+100, 32byte)  varptr(st)+100 を基点に操作(32byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DNS_QUERY_RAW_REQUEST
    #field int version
    #field int resultsVersion
    #field int dnsQueryRawSize
    #field intptr dnsQueryRaw
    #field intptr dnsQueryName
    #field short dnsQueryType
    #field int64 queryOptions
    #field int interfaceIndex
    #field intptr queryCompletionCallback
    #field intptr queryContext
    #field int64 queryRawOptions
    #field int customServersSize
    #field intptr customServers
    #field int protocol
    #field byte Anonymous 32
#endstruct

stdim st, DNS_QUERY_RAW_REQUEST        ; NSTRUCT 変数を確保
st->version = 100
mes "version=" + st->version
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。