DNS_QUERY_REQUEST3
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Version | DWORD | 4 | +0 | +0 | 構造体のバージョンです。DNS_QUERY_REQUEST_VERSION3 (値は 3) でなければなりません。 |
| QueryName | LPWSTR | 8/4 | +8 | +4 | クエリする DNS 名を表す文字列へのポインターです。 メモ
QueryName が NULL の場合、クエリはローカル コンピューター名に対して行われます。 |
| QueryType | WORD | 2 | +16 | +8 | クエリの対象となるリソース レコード (RR) の DNS レコードの種類 を表す値です。QueryType は、DNS_QUERY_RESULT 構造体で返される pQueryRecords が指すデータの形式を決定します。たとえば、wType の値が DNS_TYPE_A の場合、pQueryRecords が指すデータの形式は DNS_A_DATA になります。 |
| QueryOptions | ULONGLONG | 8 | +24 | +16 | DNS クエリで使用する DNS クエリ オプション のビットマップを格納する値です。オプションは組み合わせることができ、すべてのオプションは DNS_QUERY_STANDARD より優先されます。 |
| pDnsServerList | DNS_ADDR_ARRAY* | 8/4 | +32 | +24 | クエリで使用する DNS サーバーの一覧を格納する DNS_ADDR_ARRAY 構造体へのポインターです。 |
| InterfaceIndex | DWORD | 4 | +40 | +28 | クエリの送信に使用するインターフェイス インデックスを格納する値です。InterfaceIndex が 0 の場合、すべてのインターフェイスが対象になります。 |
| pQueryCompletionCallback | PDNS_QUERY_COMPLETION_ROUTINE | 8/4 | +48 | +32 | DnsQueryEx の呼び出しによる非同期クエリの結果を返すために使用される DNS_QUERY_COMPLETION_ROUTINE コールバックへのポインターです。 メモ
NULL の場合、DnsQueryEx は同期的に呼び出されます。 |
| pQueryContext | void* | 8/4 | +56 | +36 | ユーザー コンテキストへのポインターです。 |
| IsNetworkQueryRequired | BOOL | 4 | +64 | +40 | 予約済みです。 |
| RequiredNetworkIndex | DWORD | 4 | +68 | +44 | 予約済みです。 |
| cCustomServers | DWORD | 4 | +72 | +48 | pCustomServers メンバーが指すカスタム サーバーの数です。 |
| pCustomServers | DNS_CUSTOM_SERVER* | 8/4 | +80 | +52 | N 個 (N は cCustomServers フィールドで指定されます) の DNS_CUSTOM_SERVER オブジェクトの配列へのポインターです。 cCustomServers が 0 の場合、pCustomServers は NULL でなければなりません。 メモ
pCustomServers と pDnsServerList の少なくとも一方は NULL でなければなりません。両方に同時に NULL 以外の値を設定することはサポートされていません。 |
公式ドキュメント
DnsQueryEx の呼び出しで使用される DNS クエリ パラメーターを格納します。
解説(Remarks)
pCustomServers で指定されたカスタム サーバーは、システムで構成された DNS サーバーをバイパスします。
クエリ名が 名前解決ポリシー テーブル (NRPT) のルールに一致する場合、カスタム サーバーは無視され、NRPT ルールのサーバーのみが使用されます。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// DNS_QUERY_REQUEST3 (x64 88 / x86 56 バイト)
typedef struct DNS_QUERY_REQUEST3 {
DWORD Version;
LPWSTR QueryName;
WORD QueryType;
ULONGLONG QueryOptions;
DNS_ADDR_ARRAY* pDnsServerList;
DWORD InterfaceIndex;
PDNS_QUERY_COMPLETION_ROUTINE pQueryCompletionCallback;
void* pQueryContext;
BOOL IsNetworkQueryRequired;
DWORD RequiredNetworkIndex;
DWORD cCustomServers;
DNS_CUSTOM_SERVER* pCustomServers;
} DNS_QUERY_REQUEST3;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DNS_QUERY_REQUEST3
{
public uint Version;
public IntPtr QueryName;
public ushort QueryType;
public ulong QueryOptions;
public IntPtr pDnsServerList;
public uint InterfaceIndex;
public IntPtr pQueryCompletionCallback;
public IntPtr pQueryContext;
[MarshalAs(UnmanagedType.Bool)] public bool IsNetworkQueryRequired;
public uint RequiredNetworkIndex;
public uint cCustomServers;
public IntPtr pCustomServers;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DNS_QUERY_REQUEST3
Public Version As UInteger
Public QueryName As IntPtr
Public QueryType As UShort
Public QueryOptions As ULong
Public pDnsServerList As IntPtr
Public InterfaceIndex As UInteger
Public pQueryCompletionCallback As IntPtr
Public pQueryContext As IntPtr
<MarshalAs(UnmanagedType.Bool)> Public IsNetworkQueryRequired As Boolean
Public RequiredNetworkIndex As UInteger
Public cCustomServers As UInteger
Public pCustomServers As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class DNS_QUERY_REQUEST3(ctypes.Structure):
_fields_ = [
("Version", wintypes.DWORD),
("QueryName", ctypes.c_void_p),
("QueryType", ctypes.c_ushort),
("QueryOptions", ctypes.c_ulonglong),
("pDnsServerList", ctypes.c_void_p),
("InterfaceIndex", wintypes.DWORD),
("pQueryCompletionCallback", ctypes.c_void_p),
("pQueryContext", ctypes.c_void_p),
("IsNetworkQueryRequired", wintypes.BOOL),
("RequiredNetworkIndex", wintypes.DWORD),
("cCustomServers", wintypes.DWORD),
("pCustomServers", ctypes.c_void_p),
]#[repr(C)]
pub struct DNS_QUERY_REQUEST3 {
pub Version: u32,
pub QueryName: *mut core::ffi::c_void,
pub QueryType: u16,
pub QueryOptions: u64,
pub pDnsServerList: *mut core::ffi::c_void,
pub InterfaceIndex: u32,
pub pQueryCompletionCallback: *mut core::ffi::c_void,
pub pQueryContext: *mut core::ffi::c_void,
pub IsNetworkQueryRequired: i32,
pub RequiredNetworkIndex: u32,
pub cCustomServers: u32,
pub pCustomServers: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type DNS_QUERY_REQUEST3 struct {
Version uint32
QueryName uintptr
QueryType uint16
QueryOptions uint64
pDnsServerList uintptr
InterfaceIndex uint32
pQueryCompletionCallback uintptr
pQueryContext uintptr
IsNetworkQueryRequired int32
RequiredNetworkIndex uint32
cCustomServers uint32
pCustomServers uintptr
}type
DNS_QUERY_REQUEST3 = record
Version: DWORD;
QueryName: Pointer;
QueryType: Word;
QueryOptions: UInt64;
pDnsServerList: Pointer;
InterfaceIndex: DWORD;
pQueryCompletionCallback: Pointer;
pQueryContext: Pointer;
IsNetworkQueryRequired: BOOL;
RequiredNetworkIndex: DWORD;
cCustomServers: DWORD;
pCustomServers: Pointer;
end;const DNS_QUERY_REQUEST3 = extern struct {
Version: u32,
QueryName: ?*anyopaque,
QueryType: u16,
QueryOptions: u64,
pDnsServerList: ?*anyopaque,
InterfaceIndex: u32,
pQueryCompletionCallback: ?*anyopaque,
pQueryContext: ?*anyopaque,
IsNetworkQueryRequired: i32,
RequiredNetworkIndex: u32,
cCustomServers: u32,
pCustomServers: ?*anyopaque,
};type
DNS_QUERY_REQUEST3 {.bycopy.} = object
Version: uint32
QueryName: pointer
QueryType: uint16
QueryOptions: uint64
pDnsServerList: pointer
InterfaceIndex: uint32
pQueryCompletionCallback: pointer
pQueryContext: pointer
IsNetworkQueryRequired: int32
RequiredNetworkIndex: uint32
cCustomServers: uint32
pCustomServers: pointerstruct DNS_QUERY_REQUEST3
{
uint Version;
void* QueryName;
ushort QueryType;
ulong QueryOptions;
void* pDnsServerList;
uint InterfaceIndex;
void* pQueryCompletionCallback;
void* pQueryContext;
int IsNetworkQueryRequired;
uint RequiredNetworkIndex;
uint cCustomServers;
void* pCustomServers;
}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_REQUEST3 サイズ: 56 バイト(x86)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; Version : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; QueryName : LPWSTR (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; QueryType : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; QueryOptions : ULONGLONG (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; pDnsServerList : DNS_ADDR_ARRAY* (+24, 4byte) varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; InterfaceIndex : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; pQueryCompletionCallback : PDNS_QUERY_COMPLETION_ROUTINE (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; pQueryContext : void* (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; IsNetworkQueryRequired : BOOL (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; RequiredNetworkIndex : DWORD (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; cCustomServers : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; pCustomServers : DNS_CUSTOM_SERVER* (+52, 4byte) varptr(st)+52 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DNS_QUERY_REQUEST3 サイズ: 88 バイト(x64)
dim st, 22 ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; Version : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; QueryName : LPWSTR (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; QueryType : WORD (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; QueryOptions : ULONGLONG (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; pDnsServerList : DNS_ADDR_ARRAY* (+32, 8byte) varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; InterfaceIndex : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; pQueryCompletionCallback : PDNS_QUERY_COMPLETION_ROUTINE (+48, 8byte) qpoke st,48,値 / qpeek(st,48) ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; pQueryContext : void* (+56, 8byte) qpoke st,56,値 / qpeek(st,56) ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; IsNetworkQueryRequired : BOOL (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; RequiredNetworkIndex : DWORD (+68, 4byte) st.17 = 値 / 値 = st.17 (lpoke/lpeek も可)
; cCustomServers : DWORD (+72, 4byte) st.18 = 値 / 値 = st.18 (lpoke/lpeek も可)
; pCustomServers : DNS_CUSTOM_SERVER* (+80, 8byte) varptr(st)+80 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DNS_QUERY_REQUEST3
#field int Version
#field intptr QueryName
#field short QueryType
#field int64 QueryOptions
#field intptr pDnsServerList
#field int InterfaceIndex
#field intptr pQueryCompletionCallback
#field intptr pQueryContext
#field bool IsNetworkQueryRequired
#field int RequiredNetworkIndex
#field int cCustomServers
#field intptr pCustomServers
#endstruct
stdim st, DNS_QUERY_REQUEST3 ; NSTRUCT 変数を確保
st->Version = 100
mes "Version=" + st->Version