PERSISTENT_ISCSI_LOGIN_INFOW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| TargetName | WCHAR | 448 | +0 | +0 | イニシエーターがログインするターゲットの名前を表す文字列です。 |
| IsInformationalSession | BOOLEAN | 1 | +448 | +448 | TRUE に設定した場合、このログインセッションは情報提供のみを目的とするものであり、ローカルコンピューター上で指定されたターゲットが列挙されることはありません。情報提供用のログインセッションでは、ターゲット上の LUN はプラグアンドプレイマネージャーに報告されず、そのターゲット用のデバイスドライバーも読み込まれません。 管理アプリケーションは、システムによって列挙されていないターゲットに対しても、SendScsiInquiry、SendScsiReportLuns、SendScsiReadCapcity の各関数を介してアクセスできます。 FALSE に設定した場合、ターゲット上の LUN は列挙のためにプラグアンドプレイマネージャーへ報告されます。 |
| InitiatorInstance | WCHAR | 512 | +450 | +450 | ターゲットへのログインに使用されるイニシエーターの名前を表す文字列です。 |
| InitiatorPortNumber | DWORD | 4 | +964 | +964 | セッションのログインが確立されるホストバスアダプター (HBA) のポート番号です。値が ISCSI_ANY_INITIATOR_PORT の場合、イニシエーター上のポートが現在指定されていないことを示します。 |
| TargetPortal | ISCSI_TARGET_PORTALW | 1026 | +968 | +968 | Microsoft iSCSI イニシエーターサービスがターゲットへのログオンに使用するポータルを記述する ISCSI_TARGET_PORTAL 構造体です。 |
| SecurityFlags | ULONGLONG | 8 | +2000 | +2000 | ログイン接続のセキュリティ特性を定義するビットマップです。 |
| Mappings | ISCSI_TARGET_MAPPINGW* | 8/4 | +2008 | +2008 | ターゲット、その論理ユニット、HBA、およびターゲットに到達するために使用されるバスに関する情報を格納する ISCSI_TARGET_MAPPING 構造体へのポインターです。 |
| LoginOptions | ISCSI_LOGIN_OPTIONS | 64/52 | +2016 | +2012 | 永続的なログインの特性を格納する ISCSI_LOGIN_OPTIONS 構造体です。 |
公式ドキュメント
PERSISTENT_ISCSI_LOGIN_INFO 構造体には、マシンの起動後に Microsoft iSCSI イニシエーターサービスによって確立されたログインセッションを説明する情報が格納されます。
解説(Remarks)
PERSISTENT_ISCSI_LOGIN_INFO 構造体は ReportIScsiPersistentLogins 関数と組み合わせて使用し、マシンの起動後に Microsoft Discovery Service (iscsiexe.exe) が自動的にログインセッションを開くターゲットの一覧を取得します。
iscsidsc.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして PERSISTENT_ISCSI_LOGIN_INFO を定義します。エンコーディングに依存しないエイリアスと、エンコーディングに依存するコードを混在させると、不一致が生じてコンパイルエラーや実行時エラーの原因となることがあります。詳細については、関数プロトタイプの規則 を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// ISCSI_TARGET_PORTALW (x64 1026 / x86 1026 バイト)
typedef struct ISCSI_TARGET_PORTALW {
WCHAR SymbolicName[256];
WCHAR Address[256];
WORD Socket;
} ISCSI_TARGET_PORTALW;
// ISCSI_LOGIN_OPTIONS (x64 64 / x86 52 バイト)
typedef struct ISCSI_LOGIN_OPTIONS {
DWORD Version;
DWORD InformationSpecified;
DWORD LoginFlags;
ISCSI_AUTH_TYPES AuthType;
ISCSI_DIGEST_TYPES HeaderDigest;
ISCSI_DIGEST_TYPES DataDigest;
DWORD MaximumConnections;
DWORD DefaultTime2Wait;
DWORD DefaultTime2Retain;
DWORD UsernameLength;
DWORD PasswordLength;
BYTE* Username;
BYTE* Password;
} ISCSI_LOGIN_OPTIONS;
// PERSISTENT_ISCSI_LOGIN_INFOW (x64 2080 / x86 2064 バイト)
typedef struct PERSISTENT_ISCSI_LOGIN_INFOW {
WCHAR TargetName[224];
BOOLEAN IsInformationalSession;
WCHAR InitiatorInstance[256];
DWORD InitiatorPortNumber;
ISCSI_TARGET_PORTALW TargetPortal;
ULONGLONG SecurityFlags;
ISCSI_TARGET_MAPPINGW* Mappings;
ISCSI_LOGIN_OPTIONS LoginOptions;
} PERSISTENT_ISCSI_LOGIN_INFOW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ISCSI_TARGET_PORTALW
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string SymbolicName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string Address;
public ushort Socket;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ISCSI_LOGIN_OPTIONS
{
public uint Version;
public uint InformationSpecified;
public uint LoginFlags;
public int AuthType;
public int HeaderDigest;
public int DataDigest;
public uint MaximumConnections;
public uint DefaultTime2Wait;
public uint DefaultTime2Retain;
public uint UsernameLength;
public uint PasswordLength;
public IntPtr Username;
public IntPtr Password;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PERSISTENT_ISCSI_LOGIN_INFOW
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 224)] public string TargetName;
[MarshalAs(UnmanagedType.U1)] public bool IsInformationalSession;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string InitiatorInstance;
public uint InitiatorPortNumber;
public ISCSI_TARGET_PORTALW TargetPortal;
public ulong SecurityFlags;
public IntPtr Mappings;
public ISCSI_LOGIN_OPTIONS LoginOptions;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ISCSI_TARGET_PORTALW
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public SymbolicName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Address As String
Public Socket As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ISCSI_LOGIN_OPTIONS
Public Version As UInteger
Public InformationSpecified As UInteger
Public LoginFlags As UInteger
Public AuthType As Integer
Public HeaderDigest As Integer
Public DataDigest As Integer
Public MaximumConnections As UInteger
Public DefaultTime2Wait As UInteger
Public DefaultTime2Retain As UInteger
Public UsernameLength As UInteger
Public PasswordLength As UInteger
Public Username As IntPtr
Public Password As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PERSISTENT_ISCSI_LOGIN_INFOW
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=224)> Public TargetName As String
<MarshalAs(UnmanagedType.U1)> Public IsInformationalSession As Boolean
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public InitiatorInstance As String
Public InitiatorPortNumber As UInteger
Public TargetPortal As ISCSI_TARGET_PORTALW
Public SecurityFlags As ULong
Public Mappings As IntPtr
Public LoginOptions As ISCSI_LOGIN_OPTIONS
End Structureimport ctypes
from ctypes import wintypes
class ISCSI_TARGET_PORTALW(ctypes.Structure):
_fields_ = [
("SymbolicName", ctypes.c_wchar * 256),
("Address", ctypes.c_wchar * 256),
("Socket", ctypes.c_ushort),
]
class ISCSI_LOGIN_OPTIONS(ctypes.Structure):
_fields_ = [
("Version", wintypes.DWORD),
("InformationSpecified", wintypes.DWORD),
("LoginFlags", wintypes.DWORD),
("AuthType", ctypes.c_int),
("HeaderDigest", ctypes.c_int),
("DataDigest", ctypes.c_int),
("MaximumConnections", wintypes.DWORD),
("DefaultTime2Wait", wintypes.DWORD),
("DefaultTime2Retain", wintypes.DWORD),
("UsernameLength", wintypes.DWORD),
("PasswordLength", wintypes.DWORD),
("Username", ctypes.c_void_p),
("Password", ctypes.c_void_p),
]
class PERSISTENT_ISCSI_LOGIN_INFOW(ctypes.Structure):
_fields_ = [
("TargetName", ctypes.c_wchar * 224),
("IsInformationalSession", ctypes.c_byte),
("InitiatorInstance", ctypes.c_wchar * 256),
("InitiatorPortNumber", wintypes.DWORD),
("TargetPortal", ISCSI_TARGET_PORTALW),
("SecurityFlags", ctypes.c_ulonglong),
("Mappings", ctypes.c_void_p),
("LoginOptions", ISCSI_LOGIN_OPTIONS),
]#[repr(C)]
pub struct ISCSI_TARGET_PORTALW {
pub SymbolicName: [u16; 256],
pub Address: [u16; 256],
pub Socket: u16,
}
#[repr(C)]
pub struct ISCSI_LOGIN_OPTIONS {
pub Version: u32,
pub InformationSpecified: u32,
pub LoginFlags: u32,
pub AuthType: i32,
pub HeaderDigest: i32,
pub DataDigest: i32,
pub MaximumConnections: u32,
pub DefaultTime2Wait: u32,
pub DefaultTime2Retain: u32,
pub UsernameLength: u32,
pub PasswordLength: u32,
pub Username: *mut core::ffi::c_void,
pub Password: *mut core::ffi::c_void,
}
#[repr(C)]
pub struct PERSISTENT_ISCSI_LOGIN_INFOW {
pub TargetName: [u16; 224],
pub IsInformationalSession: u8,
pub InitiatorInstance: [u16; 256],
pub InitiatorPortNumber: u32,
pub TargetPortal: ISCSI_TARGET_PORTALW,
pub SecurityFlags: u64,
pub Mappings: *mut core::ffi::c_void,
pub LoginOptions: ISCSI_LOGIN_OPTIONS,
}import "golang.org/x/sys/windows"
type ISCSI_TARGET_PORTALW struct {
SymbolicName [256]uint16
Address [256]uint16
Socket uint16
}
type ISCSI_LOGIN_OPTIONS struct {
Version uint32
InformationSpecified uint32
LoginFlags uint32
AuthType int32
HeaderDigest int32
DataDigest int32
MaximumConnections uint32
DefaultTime2Wait uint32
DefaultTime2Retain uint32
UsernameLength uint32
PasswordLength uint32
Username uintptr
Password uintptr
}
type PERSISTENT_ISCSI_LOGIN_INFOW struct {
TargetName [224]uint16
IsInformationalSession byte
InitiatorInstance [256]uint16
InitiatorPortNumber uint32
TargetPortal ISCSI_TARGET_PORTALW
SecurityFlags uint64
Mappings uintptr
LoginOptions ISCSI_LOGIN_OPTIONS
}type
ISCSI_TARGET_PORTALW = record
SymbolicName: array[0..255] of WideChar;
Address: array[0..255] of WideChar;
Socket: Word;
end;
ISCSI_LOGIN_OPTIONS = record
Version: DWORD;
InformationSpecified: DWORD;
LoginFlags: DWORD;
AuthType: Integer;
HeaderDigest: Integer;
DataDigest: Integer;
MaximumConnections: DWORD;
DefaultTime2Wait: DWORD;
DefaultTime2Retain: DWORD;
UsernameLength: DWORD;
PasswordLength: DWORD;
Username: Pointer;
Password: Pointer;
end;
PERSISTENT_ISCSI_LOGIN_INFOW = record
TargetName: array[0..223] of WideChar;
IsInformationalSession: ByteBool;
InitiatorInstance: array[0..255] of WideChar;
InitiatorPortNumber: DWORD;
TargetPortal: ISCSI_TARGET_PORTALW;
SecurityFlags: UInt64;
Mappings: Pointer;
LoginOptions: ISCSI_LOGIN_OPTIONS;
end;const ISCSI_TARGET_PORTALW = extern struct {
SymbolicName: [256]u16,
Address: [256]u16,
Socket: u16,
};
const ISCSI_LOGIN_OPTIONS = extern struct {
Version: u32,
InformationSpecified: u32,
LoginFlags: u32,
AuthType: i32,
HeaderDigest: i32,
DataDigest: i32,
MaximumConnections: u32,
DefaultTime2Wait: u32,
DefaultTime2Retain: u32,
UsernameLength: u32,
PasswordLength: u32,
Username: ?*anyopaque,
Password: ?*anyopaque,
};
const PERSISTENT_ISCSI_LOGIN_INFOW = extern struct {
TargetName: [224]u16,
IsInformationalSession: u8,
InitiatorInstance: [256]u16,
InitiatorPortNumber: u32,
TargetPortal: ISCSI_TARGET_PORTALW,
SecurityFlags: u64,
Mappings: ?*anyopaque,
LoginOptions: ISCSI_LOGIN_OPTIONS,
};type
ISCSI_TARGET_PORTALW {.bycopy.} = object
SymbolicName: array[256, uint16]
Address: array[256, uint16]
Socket: uint16
ISCSI_LOGIN_OPTIONS {.bycopy.} = object
Version: uint32
InformationSpecified: uint32
LoginFlags: uint32
AuthType: int32
HeaderDigest: int32
DataDigest: int32
MaximumConnections: uint32
DefaultTime2Wait: uint32
DefaultTime2Retain: uint32
UsernameLength: uint32
PasswordLength: uint32
Username: pointer
Password: pointer
PERSISTENT_ISCSI_LOGIN_INFOW {.bycopy.} = object
TargetName: array[224, uint16]
IsInformationalSession: uint8
InitiatorInstance: array[256, uint16]
InitiatorPortNumber: uint32
TargetPortal: ISCSI_TARGET_PORTALW
SecurityFlags: uint64
Mappings: pointer
LoginOptions: ISCSI_LOGIN_OPTIONSstruct ISCSI_TARGET_PORTALW
{
wchar[256] SymbolicName;
wchar[256] Address;
ushort Socket;
}
struct ISCSI_LOGIN_OPTIONS
{
uint Version;
uint InformationSpecified;
uint LoginFlags;
int AuthType;
int HeaderDigest;
int DataDigest;
uint MaximumConnections;
uint DefaultTime2Wait;
uint DefaultTime2Retain;
uint UsernameLength;
uint PasswordLength;
void* Username;
void* Password;
}
struct PERSISTENT_ISCSI_LOGIN_INFOW
{
wchar[224] TargetName;
ubyte IsInformationalSession;
wchar[256] InitiatorInstance;
uint InitiatorPortNumber;
ISCSI_TARGET_PORTALW TargetPortal;
ulong SecurityFlags;
void* Mappings;
ISCSI_LOGIN_OPTIONS LoginOptions;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PERSISTENT_ISCSI_LOGIN_INFOW サイズ: 2064 バイト(x86)
dim st, 516 ; 4byte整数×516(構造体サイズ 2064 / 4 切り上げ)
; TargetName : WCHAR (+0, 448byte) varptr(st)+0 を基点に操作(448byte:入れ子/配列)
; IsInformationalSession : BOOLEAN (+448, 1byte) poke st,448,値 / 値 = peek(st,448)
; InitiatorInstance : WCHAR (+450, 512byte) varptr(st)+450 を基点に操作(512byte:入れ子/配列)
; InitiatorPortNumber : DWORD (+964, 4byte) st.241 = 値 / 値 = st.241 (lpoke/lpeek も可)
; TargetPortal : ISCSI_TARGET_PORTALW (+968, 1026byte) varptr(st)+968 を基点に操作(1026byte:入れ子/配列)
; SecurityFlags : ULONGLONG (+2000, 8byte) qpoke st,2000,値 / qpeek(st,2000) ※IronHSPのみ。3.7/3.8は lpoke st,2000,下位 : lpoke st,2004,上位
; Mappings : ISCSI_TARGET_MAPPINGW* (+2008, 4byte) varptr(st)+2008 を基点に操作(4byte:入れ子/配列)
; LoginOptions : ISCSI_LOGIN_OPTIONS (+2012, 52byte) varptr(st)+2012 を基点に操作(52byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PERSISTENT_ISCSI_LOGIN_INFOW サイズ: 2080 バイト(x64)
dim st, 520 ; 4byte整数×520(構造体サイズ 2080 / 4 切り上げ)
; TargetName : WCHAR (+0, 448byte) varptr(st)+0 を基点に操作(448byte:入れ子/配列)
; IsInformationalSession : BOOLEAN (+448, 1byte) poke st,448,値 / 値 = peek(st,448)
; InitiatorInstance : WCHAR (+450, 512byte) varptr(st)+450 を基点に操作(512byte:入れ子/配列)
; InitiatorPortNumber : DWORD (+964, 4byte) st.241 = 値 / 値 = st.241 (lpoke/lpeek も可)
; TargetPortal : ISCSI_TARGET_PORTALW (+968, 1026byte) varptr(st)+968 を基点に操作(1026byte:入れ子/配列)
; SecurityFlags : ULONGLONG (+2000, 8byte) qpoke st,2000,値 / qpeek(st,2000) ※IronHSPのみ。3.7/3.8は lpoke st,2000,下位 : lpoke st,2004,上位
; Mappings : ISCSI_TARGET_MAPPINGW* (+2008, 8byte) varptr(st)+2008 を基点に操作(8byte:入れ子/配列)
; LoginOptions : ISCSI_LOGIN_OPTIONS (+2016, 64byte) varptr(st)+2016 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global ISCSI_TARGET_PORTALW
#field wchar SymbolicName 256
#field wchar Address 256
#field short Socket
#endstruct
#defstruct global ISCSI_LOGIN_OPTIONS
#field int Version
#field int InformationSpecified
#field int LoginFlags
#field int AuthType
#field int HeaderDigest
#field int DataDigest
#field int MaximumConnections
#field int DefaultTime2Wait
#field int DefaultTime2Retain
#field int UsernameLength
#field int PasswordLength
#field intptr Username
#field intptr Password
#endstruct
#defstruct global PERSISTENT_ISCSI_LOGIN_INFOW
#field wchar TargetName 224
#field bool1 IsInformationalSession
#field wchar InitiatorInstance 256
#field int InitiatorPortNumber
#field ISCSI_TARGET_PORTALW TargetPortal
#field int64 SecurityFlags
#field intptr Mappings
#field ISCSI_LOGIN_OPTIONS LoginOptions
#endstruct
stdim st, PERSISTENT_ISCSI_LOGIN_INFOW ; NSTRUCT 変数を確保
st->IsInformationalSession = 100
mes "IsInformationalSession=" + st->IsInformationalSession