Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › TRUSTED_DOMAIN_INFORMATION_EX2

TRUSTED_DOMAIN_INFORMATION_EX2

構造体
サイズx64: 64 バイト / x86: 40 バイト

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

フィールド

フィールドサイズx64x86説明
NameLSA_UNICODE_STRING16/8+0+0信頼ドメインのDNS名(LSA_UNICODE_STRING)。
FlatNameLSA_UNICODE_STRING16/8+16+8信頼ドメインのNetBIOS(フラット)名(LSA_UNICODE_STRING)。
SidPSID8/4+32+16信頼ドメインのSID。
TrustDirectionDWORD4+40+20信頼の方向(受信/送信/双方向)を示す値。
TrustTypeDWORD4+44+24信頼の種類(Windows/MIT等)を示す値。
TrustAttributesDWORD4+48+28信頼属性フラグ(推移的/フォレスト等)。
ForestTrustLengthDWORD4+52+32ForestTrustInfoのバイト長。
ForestTrustInfoBYTE*8/4+56+36フォレスト信頼情報の生データへのポインタ。

各言語での定義

#include <windows.h>

// LSA_UNICODE_STRING  (x64 16 / x86 8 バイト)
typedef struct LSA_UNICODE_STRING {
    WORD Length;
    WORD MaximumLength;
    LPWSTR Buffer;
} LSA_UNICODE_STRING;

// TRUSTED_DOMAIN_INFORMATION_EX2  (x64 64 / x86 40 バイト)
typedef struct TRUSTED_DOMAIN_INFORMATION_EX2 {
    LSA_UNICODE_STRING Name;
    LSA_UNICODE_STRING FlatName;
    PSID Sid;
    DWORD TrustDirection;
    DWORD TrustType;
    DWORD TrustAttributes;
    DWORD ForestTrustLength;
    BYTE* ForestTrustInfo;
} TRUSTED_DOMAIN_INFORMATION_EX2;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LSA_UNICODE_STRING
{
    public ushort Length;
    public ushort MaximumLength;
    public IntPtr Buffer;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TRUSTED_DOMAIN_INFORMATION_EX2
{
    public LSA_UNICODE_STRING Name;
    public LSA_UNICODE_STRING FlatName;
    public IntPtr Sid;
    public uint TrustDirection;
    public uint TrustType;
    public uint TrustAttributes;
    public uint ForestTrustLength;
    public IntPtr ForestTrustInfo;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure LSA_UNICODE_STRING
    Public Length As UShort
    Public MaximumLength As UShort
    Public Buffer As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TRUSTED_DOMAIN_INFORMATION_EX2
    Public Name As LSA_UNICODE_STRING
    Public FlatName As LSA_UNICODE_STRING
    Public Sid As IntPtr
    Public TrustDirection As UInteger
    Public TrustType As UInteger
    Public TrustAttributes As UInteger
    Public ForestTrustLength As UInteger
    Public ForestTrustInfo As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class LSA_UNICODE_STRING(ctypes.Structure):
    _fields_ = [
        ("Length", ctypes.c_ushort),
        ("MaximumLength", ctypes.c_ushort),
        ("Buffer", ctypes.c_void_p),
    ]

class TRUSTED_DOMAIN_INFORMATION_EX2(ctypes.Structure):
    _fields_ = [
        ("Name", LSA_UNICODE_STRING),
        ("FlatName", LSA_UNICODE_STRING),
        ("Sid", ctypes.c_void_p),
        ("TrustDirection", wintypes.DWORD),
        ("TrustType", wintypes.DWORD),
        ("TrustAttributes", wintypes.DWORD),
        ("ForestTrustLength", wintypes.DWORD),
        ("ForestTrustInfo", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct LSA_UNICODE_STRING {
    pub Length: u16,
    pub MaximumLength: u16,
    pub Buffer: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct TRUSTED_DOMAIN_INFORMATION_EX2 {
    pub Name: LSA_UNICODE_STRING,
    pub FlatName: LSA_UNICODE_STRING,
    pub Sid: *mut core::ffi::c_void,
    pub TrustDirection: u32,
    pub TrustType: u32,
    pub TrustAttributes: u32,
    pub ForestTrustLength: u32,
    pub ForestTrustInfo: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type LSA_UNICODE_STRING struct {
	Length uint16
	MaximumLength uint16
	Buffer uintptr
}

type TRUSTED_DOMAIN_INFORMATION_EX2 struct {
	Name LSA_UNICODE_STRING
	FlatName LSA_UNICODE_STRING
	Sid uintptr
	TrustDirection uint32
	TrustType uint32
	TrustAttributes uint32
	ForestTrustLength uint32
	ForestTrustInfo uintptr
}
type
  LSA_UNICODE_STRING = record
    Length: Word;
    MaximumLength: Word;
    Buffer: Pointer;
  end;

  TRUSTED_DOMAIN_INFORMATION_EX2 = record
    Name: LSA_UNICODE_STRING;
    FlatName: LSA_UNICODE_STRING;
    Sid: Pointer;
    TrustDirection: DWORD;
    TrustType: DWORD;
    TrustAttributes: DWORD;
    ForestTrustLength: DWORD;
    ForestTrustInfo: Pointer;
  end;
const LSA_UNICODE_STRING = extern struct {
    Length: u16,
    MaximumLength: u16,
    Buffer: ?*anyopaque,
};

const TRUSTED_DOMAIN_INFORMATION_EX2 = extern struct {
    Name: LSA_UNICODE_STRING,
    FlatName: LSA_UNICODE_STRING,
    Sid: ?*anyopaque,
    TrustDirection: u32,
    TrustType: u32,
    TrustAttributes: u32,
    ForestTrustLength: u32,
    ForestTrustInfo: ?*anyopaque,
};
type
  LSA_UNICODE_STRING {.bycopy.} = object
    Length: uint16
    MaximumLength: uint16
    Buffer: pointer

  TRUSTED_DOMAIN_INFORMATION_EX2 {.bycopy.} = object
    Name: LSA_UNICODE_STRING
    FlatName: LSA_UNICODE_STRING
    Sid: pointer
    TrustDirection: uint32
    TrustType: uint32
    TrustAttributes: uint32
    ForestTrustLength: uint32
    ForestTrustInfo: pointer
struct LSA_UNICODE_STRING
{
    ushort Length;
    ushort MaximumLength;
    void* Buffer;
}

struct TRUSTED_DOMAIN_INFORMATION_EX2
{
    LSA_UNICODE_STRING Name;
    LSA_UNICODE_STRING FlatName;
    void* Sid;
    uint TrustDirection;
    uint TrustType;
    uint TrustAttributes;
    uint ForestTrustLength;
    void* ForestTrustInfo;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; TRUSTED_DOMAIN_INFORMATION_EX2 サイズ: 40 バイト(x86)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; Name : LSA_UNICODE_STRING (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; FlatName : LSA_UNICODE_STRING (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; Sid : PSID (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; TrustDirection : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; TrustType : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; TrustAttributes : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ForestTrustLength : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ForestTrustInfo : BYTE* (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TRUSTED_DOMAIN_INFORMATION_EX2 サイズ: 64 バイト(x64)
dim st, 16    ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; Name : LSA_UNICODE_STRING (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; FlatName : LSA_UNICODE_STRING (+16, 16byte)  varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; Sid : PSID (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; TrustDirection : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; TrustType : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; TrustAttributes : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; ForestTrustLength : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; ForestTrustInfo : BYTE* (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global LSA_UNICODE_STRING
    #field short Length
    #field short MaximumLength
    #field intptr Buffer
#endstruct

#defstruct global TRUSTED_DOMAIN_INFORMATION_EX2
    #field LSA_UNICODE_STRING Name
    #field LSA_UNICODE_STRING FlatName
    #field intptr Sid
    #field int TrustDirection
    #field int TrustType
    #field int TrustAttributes
    #field int ForestTrustLength
    #field intptr ForestTrustInfo
#endstruct

stdim st, TRUSTED_DOMAIN_INFORMATION_EX2        ; NSTRUCT 変数を確保
st->TrustDirection = 100
mes "TrustDirection=" + st->TrustDirection