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

NCRYPT_KEY_ACCESS_POLICY_BLOB

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

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

フィールド

フィールドサイズx64x86説明
dwVersionDWORD4+0+0このアクセスポリシーBLOBのバージョン番号。
dwPolicyFlagsDWORD4+4+4アクセスポリシーフラグ。鍵使用に必要な認可条件を示す。
cbUserSidDWORD4+8+8ユーザーSIDデータのバイト長。
cbApplicationSidDWORD4+12+12アプリケーションSID(アプリ署名ハッシュ)データのバイト長。

各言語での定義

#include <windows.h>

// NCRYPT_KEY_ACCESS_POLICY_BLOB  (x64 16 / x86 16 バイト)
typedef struct NCRYPT_KEY_ACCESS_POLICY_BLOB {
    DWORD dwVersion;
    DWORD dwPolicyFlags;
    DWORD cbUserSid;
    DWORD cbApplicationSid;
} NCRYPT_KEY_ACCESS_POLICY_BLOB;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NCRYPT_KEY_ACCESS_POLICY_BLOB
{
    public uint dwVersion;
    public uint dwPolicyFlags;
    public uint cbUserSid;
    public uint cbApplicationSid;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NCRYPT_KEY_ACCESS_POLICY_BLOB
    Public dwVersion As UInteger
    Public dwPolicyFlags As UInteger
    Public cbUserSid As UInteger
    Public cbApplicationSid As UInteger
End Structure
import ctypes
from ctypes import wintypes

class NCRYPT_KEY_ACCESS_POLICY_BLOB(ctypes.Structure):
    _fields_ = [
        ("dwVersion", wintypes.DWORD),
        ("dwPolicyFlags", wintypes.DWORD),
        ("cbUserSid", wintypes.DWORD),
        ("cbApplicationSid", wintypes.DWORD),
    ]
#[repr(C)]
pub struct NCRYPT_KEY_ACCESS_POLICY_BLOB {
    pub dwVersion: u32,
    pub dwPolicyFlags: u32,
    pub cbUserSid: u32,
    pub cbApplicationSid: u32,
}
import "golang.org/x/sys/windows"

type NCRYPT_KEY_ACCESS_POLICY_BLOB struct {
	dwVersion uint32
	dwPolicyFlags uint32
	cbUserSid uint32
	cbApplicationSid uint32
}
type
  NCRYPT_KEY_ACCESS_POLICY_BLOB = record
    dwVersion: DWORD;
    dwPolicyFlags: DWORD;
    cbUserSid: DWORD;
    cbApplicationSid: DWORD;
  end;
const NCRYPT_KEY_ACCESS_POLICY_BLOB = extern struct {
    dwVersion: u32,
    dwPolicyFlags: u32,
    cbUserSid: u32,
    cbApplicationSid: u32,
};
type
  NCRYPT_KEY_ACCESS_POLICY_BLOB {.bycopy.} = object
    dwVersion: uint32
    dwPolicyFlags: uint32
    cbUserSid: uint32
    cbApplicationSid: uint32
struct NCRYPT_KEY_ACCESS_POLICY_BLOB
{
    uint dwVersion;
    uint dwPolicyFlags;
    uint cbUserSid;
    uint cbApplicationSid;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NCRYPT_KEY_ACCESS_POLICY_BLOB サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; dwVersion : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwPolicyFlags : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; cbUserSid : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; cbApplicationSid : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global NCRYPT_KEY_ACCESS_POLICY_BLOB
    #field int dwVersion
    #field int dwPolicyFlags
    #field int cbUserSid
    #field int cbApplicationSid
#endstruct

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