Win32 API 日本語リファレンス
ホームSecurity.Credentials › CREDENTIALA

CREDENTIALA

構造体
サイズx64: 80 バイト / x86: 52 バイト

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

フィールド

フィールドサイズx64x86説明
FlagsCRED_FLAGS4+0+0資格情報の特性を示すCRED_FLAGSビット値。
TypeCRED_TYPE4+4+4資格情報の種別を示すCRED_TYPE値。
TargetNameLPSTR8/4+8+8資格情報が適用される対象名(ANSI)。
CommentLPSTR8/4+16+12資格情報に付随するコメント文字列(ANSI)。NULL可。
LastWrittenFILETIME8+24+16資格情報が最後に書き込まれた日時(FILETIME)。
CredentialBlobSizeDWORD4+32+24CredentialBlobのバイト長。
CredentialBlobBYTE*8/4+40+28パスワード等の秘密データへのポインタ。
PersistCRED_PERSIST4+48+32資格情報の永続化範囲を示すCRED_PERSIST値。
AttributeCountDWORD4+52+36Attributesが指す属性配列の要素数。
AttributesCREDENTIAL_ATTRIBUTEA*8/4+56+40アプリ定義の属性配列へのポインタ(ANSI)。NULL可。
TargetAliasLPSTR8/4+64+44対象名の別名(ANSI)。NULL可。
UserNameLPSTR8/4+72+48資格情報のユーザー名(ANSI)。

各言語での定義

#include <windows.h>

// FILETIME  (x64 8 / x86 8 バイト)
typedef struct FILETIME {
    DWORD dwLowDateTime;
    DWORD dwHighDateTime;
} FILETIME;

// CREDENTIALA  (x64 80 / x86 52 バイト)
typedef struct CREDENTIALA {
    CRED_FLAGS Flags;
    CRED_TYPE Type;
    LPSTR TargetName;
    LPSTR Comment;
    FILETIME LastWritten;
    DWORD CredentialBlobSize;
    BYTE* CredentialBlob;
    CRED_PERSIST Persist;
    DWORD AttributeCount;
    CREDENTIAL_ATTRIBUTEA* Attributes;
    LPSTR TargetAlias;
    LPSTR UserName;
} CREDENTIALA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FILETIME
{
    public uint dwLowDateTime;
    public uint dwHighDateTime;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CREDENTIALA
{
    public uint Flags;
    public uint Type;
    public IntPtr TargetName;
    public IntPtr Comment;
    public FILETIME LastWritten;
    public uint CredentialBlobSize;
    public IntPtr CredentialBlob;
    public uint Persist;
    public uint AttributeCount;
    public IntPtr Attributes;
    public IntPtr TargetAlias;
    public IntPtr UserName;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FILETIME
    Public dwLowDateTime As UInteger
    Public dwHighDateTime As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CREDENTIALA
    Public Flags As UInteger
    Public Type As UInteger
    Public TargetName As IntPtr
    Public Comment As IntPtr
    Public LastWritten As FILETIME
    Public CredentialBlobSize As UInteger
    Public CredentialBlob As IntPtr
    Public Persist As UInteger
    Public AttributeCount As UInteger
    Public Attributes As IntPtr
    Public TargetAlias As IntPtr
    Public UserName As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class FILETIME(ctypes.Structure):
    _fields_ = [
        ("dwLowDateTime", wintypes.DWORD),
        ("dwHighDateTime", wintypes.DWORD),
    ]

class CREDENTIALA(ctypes.Structure):
    _fields_ = [
        ("Flags", wintypes.DWORD),
        ("Type", wintypes.DWORD),
        ("TargetName", ctypes.c_void_p),
        ("Comment", ctypes.c_void_p),
        ("LastWritten", FILETIME),
        ("CredentialBlobSize", wintypes.DWORD),
        ("CredentialBlob", ctypes.c_void_p),
        ("Persist", wintypes.DWORD),
        ("AttributeCount", wintypes.DWORD),
        ("Attributes", ctypes.c_void_p),
        ("TargetAlias", ctypes.c_void_p),
        ("UserName", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct FILETIME {
    pub dwLowDateTime: u32,
    pub dwHighDateTime: u32,
}

#[repr(C)]
pub struct CREDENTIALA {
    pub Flags: u32,
    pub Type: u32,
    pub TargetName: *mut core::ffi::c_void,
    pub Comment: *mut core::ffi::c_void,
    pub LastWritten: FILETIME,
    pub CredentialBlobSize: u32,
    pub CredentialBlob: *mut core::ffi::c_void,
    pub Persist: u32,
    pub AttributeCount: u32,
    pub Attributes: *mut core::ffi::c_void,
    pub TargetAlias: *mut core::ffi::c_void,
    pub UserName: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type FILETIME struct {
	dwLowDateTime uint32
	dwHighDateTime uint32
}

type CREDENTIALA struct {
	Flags uint32
	Type uint32
	TargetName uintptr
	Comment uintptr
	LastWritten FILETIME
	CredentialBlobSize uint32
	CredentialBlob uintptr
	Persist uint32
	AttributeCount uint32
	Attributes uintptr
	TargetAlias uintptr
	UserName uintptr
}
type
  FILETIME = record
    dwLowDateTime: DWORD;
    dwHighDateTime: DWORD;
  end;

  CREDENTIALA = record
    Flags: DWORD;
    Type: DWORD;
    TargetName: Pointer;
    Comment: Pointer;
    LastWritten: FILETIME;
    CredentialBlobSize: DWORD;
    CredentialBlob: Pointer;
    Persist: DWORD;
    AttributeCount: DWORD;
    Attributes: Pointer;
    TargetAlias: Pointer;
    UserName: Pointer;
  end;
const FILETIME = extern struct {
    dwLowDateTime: u32,
    dwHighDateTime: u32,
};

const CREDENTIALA = extern struct {
    Flags: u32,
    Type: u32,
    TargetName: ?*anyopaque,
    Comment: ?*anyopaque,
    LastWritten: FILETIME,
    CredentialBlobSize: u32,
    CredentialBlob: ?*anyopaque,
    Persist: u32,
    AttributeCount: u32,
    Attributes: ?*anyopaque,
    TargetAlias: ?*anyopaque,
    UserName: ?*anyopaque,
};
type
  FILETIME {.bycopy.} = object
    dwLowDateTime: uint32
    dwHighDateTime: uint32

  CREDENTIALA {.bycopy.} = object
    Flags: uint32
    Type: uint32
    TargetName: pointer
    Comment: pointer
    LastWritten: FILETIME
    CredentialBlobSize: uint32
    CredentialBlob: pointer
    Persist: uint32
    AttributeCount: uint32
    Attributes: pointer
    TargetAlias: pointer
    UserName: pointer
struct FILETIME
{
    uint dwLowDateTime;
    uint dwHighDateTime;
}

struct CREDENTIALA
{
    uint Flags;
    uint Type;
    void* TargetName;
    void* Comment;
    FILETIME LastWritten;
    uint CredentialBlobSize;
    void* CredentialBlob;
    uint Persist;
    uint AttributeCount;
    void* Attributes;
    void* TargetAlias;
    void* UserName;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; CREDENTIALA サイズ: 52 バイト(x86)
dim st, 13    ; 4byte整数×13(構造体サイズ 52 / 4 切り上げ)
; Flags : CRED_FLAGS (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Type : CRED_TYPE (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; TargetName : LPSTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Comment : LPSTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; LastWritten : FILETIME (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; CredentialBlobSize : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; CredentialBlob : BYTE* (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; Persist : CRED_PERSIST (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; AttributeCount : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; Attributes : CREDENTIAL_ATTRIBUTEA* (+40, 4byte)  varptr(st)+40 を基点に操作(4byte:入れ子/配列)
; TargetAlias : LPSTR (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; UserName : LPSTR (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CREDENTIALA サイズ: 80 バイト(x64)
dim st, 20    ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; Flags : CRED_FLAGS (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Type : CRED_TYPE (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; TargetName : LPSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; Comment : LPSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; LastWritten : FILETIME (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; CredentialBlobSize : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; CredentialBlob : BYTE* (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; Persist : CRED_PERSIST (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; AttributeCount : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; Attributes : CREDENTIAL_ATTRIBUTEA* (+56, 8byte)  varptr(st)+56 を基点に操作(8byte:入れ子/配列)
; TargetAlias : LPSTR (+64, 8byte)  qpoke st,64,値 / qpeek(st,64)  ※IronHSPのみ。3.7/3.8は lpoke st,64,下位 : lpoke st,68,上位
; UserName : LPSTR (+72, 8byte)  qpoke st,72,値 / qpeek(st,72)  ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global FILETIME
    #field int dwLowDateTime
    #field int dwHighDateTime
#endstruct

#defstruct global CREDENTIALA
    #field int Flags
    #field int Type
    #field intptr TargetName
    #field intptr Comment
    #field FILETIME LastWritten
    #field int CredentialBlobSize
    #field intptr CredentialBlob
    #field int Persist
    #field int AttributeCount
    #field intptr Attributes
    #field intptr TargetAlias
    #field intptr UserName
#endstruct

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