ホーム › Security.Authentication.Identity › ENCRYPTED_CREDENTIALW
ENCRYPTED_CREDENTIALW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Cred | CREDENTIALW | 80/52 | +0 | +0 | 暗号化対象となる資格情報を保持するCREDENTIALW構造を埋め込む。 |
| ClearCredentialBlobSize | DWORD | 4 | +80 | +52 | 暗号化前の平文資格情報ブロブのバイト数を示す。 |
各言語での定義
#include <windows.h>
// FILETIME (x64 8 / x86 8 バイト)
typedef struct FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;
// CREDENTIALW (x64 80 / x86 52 バイト)
typedef struct CREDENTIALW {
CRED_FLAGS Flags;
CRED_TYPE Type;
LPWSTR TargetName;
LPWSTR Comment;
FILETIME LastWritten;
DWORD CredentialBlobSize;
BYTE* CredentialBlob;
CRED_PERSIST Persist;
DWORD AttributeCount;
CREDENTIAL_ATTRIBUTEW* Attributes;
LPWSTR TargetAlias;
LPWSTR UserName;
} CREDENTIALW;
// ENCRYPTED_CREDENTIALW (x64 88 / x86 56 バイト)
typedef struct ENCRYPTED_CREDENTIALW {
CREDENTIALW Cred;
DWORD ClearCredentialBlobSize;
} ENCRYPTED_CREDENTIALW;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 CREDENTIALW
{
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;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ENCRYPTED_CREDENTIALW
{
public CREDENTIALW Cred;
public uint ClearCredentialBlobSize;
}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 CREDENTIALW
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
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ENCRYPTED_CREDENTIALW
Public Cred As CREDENTIALW
Public ClearCredentialBlobSize As UInteger
End Structureimport ctypes
from ctypes import wintypes
class FILETIME(ctypes.Structure):
_fields_ = [
("dwLowDateTime", wintypes.DWORD),
("dwHighDateTime", wintypes.DWORD),
]
class CREDENTIALW(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),
]
class ENCRYPTED_CREDENTIALW(ctypes.Structure):
_fields_ = [
("Cred", CREDENTIALW),
("ClearCredentialBlobSize", wintypes.DWORD),
]#[repr(C)]
pub struct FILETIME {
pub dwLowDateTime: u32,
pub dwHighDateTime: u32,
}
#[repr(C)]
pub struct CREDENTIALW {
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,
}
#[repr(C)]
pub struct ENCRYPTED_CREDENTIALW {
pub Cred: CREDENTIALW,
pub ClearCredentialBlobSize: u32,
}import "golang.org/x/sys/windows"
type FILETIME struct {
dwLowDateTime uint32
dwHighDateTime uint32
}
type CREDENTIALW 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 ENCRYPTED_CREDENTIALW struct {
Cred CREDENTIALW
ClearCredentialBlobSize uint32
}type
FILETIME = record
dwLowDateTime: DWORD;
dwHighDateTime: DWORD;
end;
CREDENTIALW = 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;
ENCRYPTED_CREDENTIALW = record
Cred: CREDENTIALW;
ClearCredentialBlobSize: DWORD;
end;const FILETIME = extern struct {
dwLowDateTime: u32,
dwHighDateTime: u32,
};
const CREDENTIALW = 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,
};
const ENCRYPTED_CREDENTIALW = extern struct {
Cred: CREDENTIALW,
ClearCredentialBlobSize: u32,
};type
FILETIME {.bycopy.} = object
dwLowDateTime: uint32
dwHighDateTime: uint32
CREDENTIALW {.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
ENCRYPTED_CREDENTIALW {.bycopy.} = object
Cred: CREDENTIALW
ClearCredentialBlobSize: uint32struct FILETIME
{
uint dwLowDateTime;
uint dwHighDateTime;
}
struct CREDENTIALW
{
uint Flags;
uint Type;
void* TargetName;
void* Comment;
FILETIME LastWritten;
uint CredentialBlobSize;
void* CredentialBlob;
uint Persist;
uint AttributeCount;
void* Attributes;
void* TargetAlias;
void* UserName;
}
struct ENCRYPTED_CREDENTIALW
{
CREDENTIALW Cred;
uint ClearCredentialBlobSize;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; ENCRYPTED_CREDENTIALW サイズ: 56 バイト(x86)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; Cred : CREDENTIALW (+0, 52byte) varptr(st)+0 を基点に操作(52byte:入れ子/配列)
; ClearCredentialBlobSize : DWORD (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ENCRYPTED_CREDENTIALW サイズ: 88 バイト(x64)
dim st, 22 ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; Cred : CREDENTIALW (+0, 80byte) varptr(st)+0 を基点に操作(80byte:入れ子/配列)
; ClearCredentialBlobSize : DWORD (+80, 4byte) st.20 = 値 / 値 = st.20 (lpoke/lpeek も可)
; ※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 CREDENTIALW
#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
#defstruct global ENCRYPTED_CREDENTIALW
#field CREDENTIALW Cred
#field int ClearCredentialBlobSize
#endstruct
stdim st, ENCRYPTED_CREDENTIALW ; NSTRUCT 変数を確保
st->ClearCredentialBlobSize = 100
mes "ClearCredentialBlobSize=" + st->ClearCredentialBlobSize