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

TRUSTED_DOMAIN_FULL_INFORMATION2

構造体
サイズx64: 120 バイト / x86: 68 バイト

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

フィールド

フィールドサイズx64x86説明
InformationTRUSTED_DOMAIN_INFORMATION_EX264/40+0+0信頼ドメインの基本拡張情報(TRUSTED_DOMAIN_INFORMATION_EX2)。
PosixOffsetTRUSTED_POSIX_OFFSET_INFO4+64+40信頼ドメインのPOSIXオフセット情報。
AuthInformationTRUSTED_DOMAIN_AUTH_INFORMATION48/24+72+44信頼ドメインの認証情報。

各言語での定義

#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;

// TRUSTED_POSIX_OFFSET_INFO  (x64 4 / x86 4 バイト)
typedef struct TRUSTED_POSIX_OFFSET_INFO {
    DWORD Offset;
} TRUSTED_POSIX_OFFSET_INFO;

// TRUSTED_DOMAIN_AUTH_INFORMATION  (x64 48 / x86 24 バイト)
typedef struct TRUSTED_DOMAIN_AUTH_INFORMATION {
    DWORD IncomingAuthInfos;
    LSA_AUTH_INFORMATION* IncomingAuthenticationInformation;
    LSA_AUTH_INFORMATION* IncomingPreviousAuthenticationInformation;
    DWORD OutgoingAuthInfos;
    LSA_AUTH_INFORMATION* OutgoingAuthenticationInformation;
    LSA_AUTH_INFORMATION* OutgoingPreviousAuthenticationInformation;
} TRUSTED_DOMAIN_AUTH_INFORMATION;

// TRUSTED_DOMAIN_FULL_INFORMATION2  (x64 120 / x86 68 バイト)
typedef struct TRUSTED_DOMAIN_FULL_INFORMATION2 {
    TRUSTED_DOMAIN_INFORMATION_EX2 Information;
    TRUSTED_POSIX_OFFSET_INFO PosixOffset;
    TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation;
} TRUSTED_DOMAIN_FULL_INFORMATION2;
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;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TRUSTED_POSIX_OFFSET_INFO
{
    public uint Offset;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TRUSTED_DOMAIN_AUTH_INFORMATION
{
    public uint IncomingAuthInfos;
    public IntPtr IncomingAuthenticationInformation;
    public IntPtr IncomingPreviousAuthenticationInformation;
    public uint OutgoingAuthInfos;
    public IntPtr OutgoingAuthenticationInformation;
    public IntPtr OutgoingPreviousAuthenticationInformation;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TRUSTED_DOMAIN_FULL_INFORMATION2
{
    public TRUSTED_DOMAIN_INFORMATION_EX2 Information;
    public TRUSTED_POSIX_OFFSET_INFO PosixOffset;
    public TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation;
}
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

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TRUSTED_POSIX_OFFSET_INFO
    Public Offset As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TRUSTED_DOMAIN_AUTH_INFORMATION
    Public IncomingAuthInfos As UInteger
    Public IncomingAuthenticationInformation As IntPtr
    Public IncomingPreviousAuthenticationInformation As IntPtr
    Public OutgoingAuthInfos As UInteger
    Public OutgoingAuthenticationInformation As IntPtr
    Public OutgoingPreviousAuthenticationInformation As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TRUSTED_DOMAIN_FULL_INFORMATION2
    Public Information As TRUSTED_DOMAIN_INFORMATION_EX2
    Public PosixOffset As TRUSTED_POSIX_OFFSET_INFO
    Public AuthInformation As TRUSTED_DOMAIN_AUTH_INFORMATION
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),
    ]

class TRUSTED_POSIX_OFFSET_INFO(ctypes.Structure):
    _fields_ = [
        ("Offset", wintypes.DWORD),
    ]

class TRUSTED_DOMAIN_AUTH_INFORMATION(ctypes.Structure):
    _fields_ = [
        ("IncomingAuthInfos", wintypes.DWORD),
        ("IncomingAuthenticationInformation", ctypes.c_void_p),
        ("IncomingPreviousAuthenticationInformation", ctypes.c_void_p),
        ("OutgoingAuthInfos", wintypes.DWORD),
        ("OutgoingAuthenticationInformation", ctypes.c_void_p),
        ("OutgoingPreviousAuthenticationInformation", ctypes.c_void_p),
    ]

class TRUSTED_DOMAIN_FULL_INFORMATION2(ctypes.Structure):
    _fields_ = [
        ("Information", TRUSTED_DOMAIN_INFORMATION_EX2),
        ("PosixOffset", TRUSTED_POSIX_OFFSET_INFO),
        ("AuthInformation", TRUSTED_DOMAIN_AUTH_INFORMATION),
    ]
#[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,
}

#[repr(C)]
pub struct TRUSTED_POSIX_OFFSET_INFO {
    pub Offset: u32,
}

#[repr(C)]
pub struct TRUSTED_DOMAIN_AUTH_INFORMATION {
    pub IncomingAuthInfos: u32,
    pub IncomingAuthenticationInformation: *mut core::ffi::c_void,
    pub IncomingPreviousAuthenticationInformation: *mut core::ffi::c_void,
    pub OutgoingAuthInfos: u32,
    pub OutgoingAuthenticationInformation: *mut core::ffi::c_void,
    pub OutgoingPreviousAuthenticationInformation: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct TRUSTED_DOMAIN_FULL_INFORMATION2 {
    pub Information: TRUSTED_DOMAIN_INFORMATION_EX2,
    pub PosixOffset: TRUSTED_POSIX_OFFSET_INFO,
    pub AuthInformation: TRUSTED_DOMAIN_AUTH_INFORMATION,
}
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 TRUSTED_POSIX_OFFSET_INFO struct {
	Offset uint32
}

type TRUSTED_DOMAIN_AUTH_INFORMATION struct {
	IncomingAuthInfos uint32
	IncomingAuthenticationInformation uintptr
	IncomingPreviousAuthenticationInformation uintptr
	OutgoingAuthInfos uint32
	OutgoingAuthenticationInformation uintptr
	OutgoingPreviousAuthenticationInformation uintptr
}

type TRUSTED_DOMAIN_FULL_INFORMATION2 struct {
	Information TRUSTED_DOMAIN_INFORMATION_EX2
	PosixOffset TRUSTED_POSIX_OFFSET_INFO
	AuthInformation TRUSTED_DOMAIN_AUTH_INFORMATION
}
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;

  TRUSTED_POSIX_OFFSET_INFO = record
    Offset: DWORD;
  end;

  TRUSTED_DOMAIN_AUTH_INFORMATION = record
    IncomingAuthInfos: DWORD;
    IncomingAuthenticationInformation: Pointer;
    IncomingPreviousAuthenticationInformation: Pointer;
    OutgoingAuthInfos: DWORD;
    OutgoingAuthenticationInformation: Pointer;
    OutgoingPreviousAuthenticationInformation: Pointer;
  end;

  TRUSTED_DOMAIN_FULL_INFORMATION2 = record
    Information: TRUSTED_DOMAIN_INFORMATION_EX2;
    PosixOffset: TRUSTED_POSIX_OFFSET_INFO;
    AuthInformation: TRUSTED_DOMAIN_AUTH_INFORMATION;
  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,
};

const TRUSTED_POSIX_OFFSET_INFO = extern struct {
    Offset: u32,
};

const TRUSTED_DOMAIN_AUTH_INFORMATION = extern struct {
    IncomingAuthInfos: u32,
    IncomingAuthenticationInformation: ?*anyopaque,
    IncomingPreviousAuthenticationInformation: ?*anyopaque,
    OutgoingAuthInfos: u32,
    OutgoingAuthenticationInformation: ?*anyopaque,
    OutgoingPreviousAuthenticationInformation: ?*anyopaque,
};

const TRUSTED_DOMAIN_FULL_INFORMATION2 = extern struct {
    Information: TRUSTED_DOMAIN_INFORMATION_EX2,
    PosixOffset: TRUSTED_POSIX_OFFSET_INFO,
    AuthInformation: TRUSTED_DOMAIN_AUTH_INFORMATION,
};
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

  TRUSTED_POSIX_OFFSET_INFO {.bycopy.} = object
    Offset: uint32

  TRUSTED_DOMAIN_AUTH_INFORMATION {.bycopy.} = object
    IncomingAuthInfos: uint32
    IncomingAuthenticationInformation: pointer
    IncomingPreviousAuthenticationInformation: pointer
    OutgoingAuthInfos: uint32
    OutgoingAuthenticationInformation: pointer
    OutgoingPreviousAuthenticationInformation: pointer

  TRUSTED_DOMAIN_FULL_INFORMATION2 {.bycopy.} = object
    Information: TRUSTED_DOMAIN_INFORMATION_EX2
    PosixOffset: TRUSTED_POSIX_OFFSET_INFO
    AuthInformation: TRUSTED_DOMAIN_AUTH_INFORMATION
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;
}

struct TRUSTED_POSIX_OFFSET_INFO
{
    uint Offset;
}

struct TRUSTED_DOMAIN_AUTH_INFORMATION
{
    uint IncomingAuthInfos;
    void* IncomingAuthenticationInformation;
    void* IncomingPreviousAuthenticationInformation;
    uint OutgoingAuthInfos;
    void* OutgoingAuthenticationInformation;
    void* OutgoingPreviousAuthenticationInformation;
}

struct TRUSTED_DOMAIN_FULL_INFORMATION2
{
    TRUSTED_DOMAIN_INFORMATION_EX2 Information;
    TRUSTED_POSIX_OFFSET_INFO PosixOffset;
    TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation;
}

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_FULL_INFORMATION2 サイズ: 68 バイト(x86)
dim st, 17    ; 4byte整数×17(構造体サイズ 68 / 4 切り上げ)
; Information : TRUSTED_DOMAIN_INFORMATION_EX2 (+0, 40byte)  varptr(st)+0 を基点に操作(40byte:入れ子/配列)
; PosixOffset : TRUSTED_POSIX_OFFSET_INFO (+40, 4byte)  varptr(st)+40 を基点に操作(4byte:入れ子/配列)
; AuthInformation : TRUSTED_DOMAIN_AUTH_INFORMATION (+44, 24byte)  varptr(st)+44 を基点に操作(24byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TRUSTED_DOMAIN_FULL_INFORMATION2 サイズ: 120 バイト(x64)
dim st, 30    ; 4byte整数×30(構造体サイズ 120 / 4 切り上げ)
; Information : TRUSTED_DOMAIN_INFORMATION_EX2 (+0, 64byte)  varptr(st)+0 を基点に操作(64byte:入れ子/配列)
; PosixOffset : TRUSTED_POSIX_OFFSET_INFO (+64, 4byte)  varptr(st)+64 を基点に操作(4byte:入れ子/配列)
; AuthInformation : TRUSTED_DOMAIN_AUTH_INFORMATION (+72, 48byte)  varptr(st)+72 を基点に操作(48byte:入れ子/配列)
; ※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

#defstruct global TRUSTED_POSIX_OFFSET_INFO
    #field int Offset
#endstruct

#defstruct global TRUSTED_DOMAIN_AUTH_INFORMATION
    #field int IncomingAuthInfos
    #field intptr IncomingAuthenticationInformation
    #field intptr IncomingPreviousAuthenticationInformation
    #field int OutgoingAuthInfos
    #field intptr OutgoingAuthenticationInformation
    #field intptr OutgoingPreviousAuthenticationInformation
#endstruct

#defstruct global TRUSTED_DOMAIN_FULL_INFORMATION2
    #field TRUSTED_DOMAIN_INFORMATION_EX2 Information
    #field TRUSTED_POSIX_OFFSET_INFO PosixOffset
    #field TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation
#endstruct

stdim st, TRUSTED_DOMAIN_FULL_INFORMATION2        ; NSTRUCT 変数を確保