ホーム › Security.Cryptography › CERT_CONTEXT
CERT_CONTEXT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwCertEncodingType | CERT_QUERY_ENCODING_TYPE | 4 | +0 | +0 | 証明書のエンコード種別(X509_ASN_ENCODING等)。 |
| pbCertEncoded | BYTE* | 8/4 | +8 | +4 | エンコード済み証明書のバイト列へのポインタ。 |
| cbCertEncoded | DWORD | 4 | +16 | +8 | pbCertEncodedのサイズ(バイト単位)。 |
| pCertInfo | CERT_INFO* | 8/4 | +24 | +12 | デコード済みの証明書情報(CERT_INFO)へのポインタ。 |
| hCertStore | HCERTSTORE | 8/4 | +32 | +16 | この証明書が属する証明書ストアのハンドル。NULL可。 |
各言語での定義
#include <windows.h>
// CERT_CONTEXT (x64 40 / x86 20 バイト)
typedef struct CERT_CONTEXT {
CERT_QUERY_ENCODING_TYPE dwCertEncodingType;
BYTE* pbCertEncoded;
DWORD cbCertEncoded;
CERT_INFO* pCertInfo;
HCERTSTORE hCertStore;
} CERT_CONTEXT;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CERT_CONTEXT
{
public uint dwCertEncodingType;
public IntPtr pbCertEncoded;
public uint cbCertEncoded;
public IntPtr pCertInfo;
public IntPtr hCertStore;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CERT_CONTEXT
Public dwCertEncodingType As UInteger
Public pbCertEncoded As IntPtr
Public cbCertEncoded As UInteger
Public pCertInfo As IntPtr
Public hCertStore As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class CERT_CONTEXT(ctypes.Structure):
_fields_ = [
("dwCertEncodingType", wintypes.DWORD),
("pbCertEncoded", ctypes.c_void_p),
("cbCertEncoded", wintypes.DWORD),
("pCertInfo", ctypes.c_void_p),
("hCertStore", ctypes.c_void_p),
]#[repr(C)]
pub struct CERT_CONTEXT {
pub dwCertEncodingType: u32,
pub pbCertEncoded: *mut core::ffi::c_void,
pub cbCertEncoded: u32,
pub pCertInfo: *mut core::ffi::c_void,
pub hCertStore: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type CERT_CONTEXT struct {
dwCertEncodingType uint32
pbCertEncoded uintptr
cbCertEncoded uint32
pCertInfo uintptr
hCertStore uintptr
}type
CERT_CONTEXT = record
dwCertEncodingType: DWORD;
pbCertEncoded: Pointer;
cbCertEncoded: DWORD;
pCertInfo: Pointer;
hCertStore: Pointer;
end;const CERT_CONTEXT = extern struct {
dwCertEncodingType: u32,
pbCertEncoded: ?*anyopaque,
cbCertEncoded: u32,
pCertInfo: ?*anyopaque,
hCertStore: ?*anyopaque,
};type
CERT_CONTEXT {.bycopy.} = object
dwCertEncodingType: uint32
pbCertEncoded: pointer
cbCertEncoded: uint32
pCertInfo: pointer
hCertStore: pointerstruct CERT_CONTEXT
{
uint dwCertEncodingType;
void* pbCertEncoded;
uint cbCertEncoded;
void* pCertInfo;
void* hCertStore;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; CERT_CONTEXT サイズ: 20 バイト(x86)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; dwCertEncodingType : CERT_QUERY_ENCODING_TYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; pbCertEncoded : BYTE* (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; cbCertEncoded : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; pCertInfo : CERT_INFO* (+12, 4byte) varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; hCertStore : HCERTSTORE (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CERT_CONTEXT サイズ: 40 バイト(x64)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; dwCertEncodingType : CERT_QUERY_ENCODING_TYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; pbCertEncoded : BYTE* (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; cbCertEncoded : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; pCertInfo : CERT_INFO* (+24, 8byte) varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; hCertStore : HCERTSTORE (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CERT_CONTEXT
#field int dwCertEncodingType
#field intptr pbCertEncoded
#field int cbCertEncoded
#field intptr pCertInfo
#field intptr hCertStore
#endstruct
stdim st, CERT_CONTEXT ; NSTRUCT 変数を確保
st->dwCertEncodingType = 100
mes "dwCertEncodingType=" + st->dwCertEncodingType