SCH_CREDENTIALS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| dwVersion | DWORD | 4 | +0 | +0 | SCH_CREDENTIALS_VERSION を設定します。 | ||||||||||||||||||||||||||||||||||||
| dwCredFormat | DWORD | 4 | +4 | +4 | カーネル モードの Schannel は次の値をサポートします。 Windows Server 2008、Windows Vista、Windows Server 2003、Windows XP および Windows XP/2000: このフラグはサポートされておらず、0 でなければなりません。
| ||||||||||||||||||||||||||||||||||||
| cCreds | DWORD | 4 | +8 | +8 | paCred 配列内の構造体の数です。 | ||||||||||||||||||||||||||||||||||||
| paCred | CERT_CONTEXT** | 8/4 | +16 | +12 | CERT_CONTEXT 構造体へのポインターの配列です。各ポインターは、アプリケーションの認証に使用する秘密キーを含む証明書を指定します。 クライアント アプリケーションでは、空のリストを渡して適切な証明書の検出を Schannel に任せるか、必要になった時点で証明書を作成することがよくあります。 | ||||||||||||||||||||||||||||||||||||
| hRootStore | HCERTSTORE | 8/4 | +24 | +16 | 省略可能。 サーバー アプリケーションでのみ有効です。アプリケーションが信頼する証明機関 (CA) の自己署名ルート証明書を格納する証明書ストアへのハンドルです。このメンバーは、クライアント認証を必要とするサーバー側アプリケーションでのみ使用されます。 | ||||||||||||||||||||||||||||||||||||
| cMappers | DWORD | 4 | +32 | +20 | 予約済みです。 | ||||||||||||||||||||||||||||||||||||
| aphMappers | _HMAPPER** | 8/4 | +40 | +24 | 予約済みです。 | ||||||||||||||||||||||||||||||||||||
| dwSessionLifespan | DWORD | 4 | +48 | +28 | Schannel がセッションをセッション キャッシュに保持するミリ秒数です。この時間が経過すると、クライアントとサーバー間の新しい接続には新しい Schannel セッションが必要になります。このメンバーの値を 0 に設定すると、既定値の 36000000 ミリ秒 (10 時間) が使用されます。 | ||||||||||||||||||||||||||||||||||||
| dwFlags | DWORD | 4 | +52 | +32 | Schannel の動作を制御するビット フラグを格納します。このメンバーには 0、または次の値の組み合わせを指定できます。
| ||||||||||||||||||||||||||||||||||||
| cTlsParameters | DWORD | 4 | +56 | +36 | pTlsParameters 配列内のエントリの数です。 SCH_CRED_MAX_SUPPORTED_PARAMETERS より多く指定するとエラーになります。 | ||||||||||||||||||||||||||||||||||||
| pTlsParameters | TLS_PARAMETERS* | 8/4 | +64 | +40 | TLS パラメーターの制限がある場合に、それを示す TLS_PARAMETERS 構造体へのポインターの配列です。制限を指定しない場合は、システムの既定値が使用されます。アプリケーションはシステムの既定値に依存することが推奨されます。 cAlpnIds == 0 かつ rgstrAlpnIds == NULL である TLS_PARAMETERS 構造体を複数含めるとエラーになります。 |
公式ドキュメント
SCH_CREDENTIALS 構造体は、Schannel 資格情報の初期化情報を格納します。
解説(Remarks)
SCH_CREDENTIALS 構造体を使用するには、UNICODE_STRING および PUNICODE_STRING と共に SCHANNEL_USE_BLACKLISTS を定義します。あるいは、Ntdef.h、SubAuth.h、または Winternl.h をインクルードします。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// SCH_CREDENTIALS (x64 72 / x86 44 バイト)
typedef struct SCH_CREDENTIALS {
DWORD dwVersion;
DWORD dwCredFormat;
DWORD cCreds;
CERT_CONTEXT** paCred;
HCERTSTORE hRootStore;
DWORD cMappers;
_HMAPPER** aphMappers;
DWORD dwSessionLifespan;
DWORD dwFlags;
DWORD cTlsParameters;
TLS_PARAMETERS* pTlsParameters;
} SCH_CREDENTIALS;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SCH_CREDENTIALS
{
public uint dwVersion;
public uint dwCredFormat;
public uint cCreds;
public IntPtr paCred;
public IntPtr hRootStore;
public uint cMappers;
public IntPtr aphMappers;
public uint dwSessionLifespan;
public uint dwFlags;
public uint cTlsParameters;
public IntPtr pTlsParameters;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SCH_CREDENTIALS
Public dwVersion As UInteger
Public dwCredFormat As UInteger
Public cCreds As UInteger
Public paCred As IntPtr
Public hRootStore As IntPtr
Public cMappers As UInteger
Public aphMappers As IntPtr
Public dwSessionLifespan As UInteger
Public dwFlags As UInteger
Public cTlsParameters As UInteger
Public pTlsParameters As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class SCH_CREDENTIALS(ctypes.Structure):
_fields_ = [
("dwVersion", wintypes.DWORD),
("dwCredFormat", wintypes.DWORD),
("cCreds", wintypes.DWORD),
("paCred", ctypes.c_void_p),
("hRootStore", ctypes.c_void_p),
("cMappers", wintypes.DWORD),
("aphMappers", ctypes.c_void_p),
("dwSessionLifespan", wintypes.DWORD),
("dwFlags", wintypes.DWORD),
("cTlsParameters", wintypes.DWORD),
("pTlsParameters", ctypes.c_void_p),
]#[repr(C)]
pub struct SCH_CREDENTIALS {
pub dwVersion: u32,
pub dwCredFormat: u32,
pub cCreds: u32,
pub paCred: *mut core::ffi::c_void,
pub hRootStore: *mut core::ffi::c_void,
pub cMappers: u32,
pub aphMappers: *mut core::ffi::c_void,
pub dwSessionLifespan: u32,
pub dwFlags: u32,
pub cTlsParameters: u32,
pub pTlsParameters: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type SCH_CREDENTIALS struct {
dwVersion uint32
dwCredFormat uint32
cCreds uint32
paCred uintptr
hRootStore uintptr
cMappers uint32
aphMappers uintptr
dwSessionLifespan uint32
dwFlags uint32
cTlsParameters uint32
pTlsParameters uintptr
}type
SCH_CREDENTIALS = record
dwVersion: DWORD;
dwCredFormat: DWORD;
cCreds: DWORD;
paCred: Pointer;
hRootStore: Pointer;
cMappers: DWORD;
aphMappers: Pointer;
dwSessionLifespan: DWORD;
dwFlags: DWORD;
cTlsParameters: DWORD;
pTlsParameters: Pointer;
end;const SCH_CREDENTIALS = extern struct {
dwVersion: u32,
dwCredFormat: u32,
cCreds: u32,
paCred: ?*anyopaque,
hRootStore: ?*anyopaque,
cMappers: u32,
aphMappers: ?*anyopaque,
dwSessionLifespan: u32,
dwFlags: u32,
cTlsParameters: u32,
pTlsParameters: ?*anyopaque,
};type
SCH_CREDENTIALS {.bycopy.} = object
dwVersion: uint32
dwCredFormat: uint32
cCreds: uint32
paCred: pointer
hRootStore: pointer
cMappers: uint32
aphMappers: pointer
dwSessionLifespan: uint32
dwFlags: uint32
cTlsParameters: uint32
pTlsParameters: pointerstruct SCH_CREDENTIALS
{
uint dwVersion;
uint dwCredFormat;
uint cCreds;
void* paCred;
void* hRootStore;
uint cMappers;
void* aphMappers;
uint dwSessionLifespan;
uint dwFlags;
uint cTlsParameters;
void* pTlsParameters;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SCH_CREDENTIALS サイズ: 44 バイト(x86)
dim st, 11 ; 4byte整数×11(構造体サイズ 44 / 4 切り上げ)
; dwVersion : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwCredFormat : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; cCreds : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; paCred : CERT_CONTEXT** (+12, 4byte) varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; hRootStore : HCERTSTORE (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; cMappers : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; aphMappers : _HMAPPER** (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; dwSessionLifespan : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; dwFlags : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; cTlsParameters : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; pTlsParameters : TLS_PARAMETERS* (+40, 4byte) varptr(st)+40 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SCH_CREDENTIALS サイズ: 72 バイト(x64)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; dwVersion : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwCredFormat : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; cCreds : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; paCred : CERT_CONTEXT** (+16, 8byte) varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; hRootStore : HCERTSTORE (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; cMappers : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; aphMappers : _HMAPPER** (+40, 8byte) qpoke st,40,値 / qpeek(st,40) ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; dwSessionLifespan : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; dwFlags : DWORD (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; cTlsParameters : DWORD (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; pTlsParameters : TLS_PARAMETERS* (+64, 8byte) varptr(st)+64 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SCH_CREDENTIALS
#field int dwVersion
#field int dwCredFormat
#field int cCreds
#field intptr paCred
#field intptr hRootStore
#field int cMappers
#field intptr aphMappers
#field int dwSessionLifespan
#field int dwFlags
#field int cTlsParameters
#field intptr pTlsParameters
#endstruct
stdim st, SCH_CREDENTIALS ; NSTRUCT 変数を確保
st->dwVersion = 100
mes "dwVersion=" + st->dwVersion