ホーム › Security.AppLocker › SAFER_CODE_PROPERTIES_V1
SAFER_CODE_PROPERTIES_V1
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbSize | DWORD | 4 | +0 | +0 | この構造体のサイズ(バイト)。バージョン識別に使用する。 |
| dwCheckFlags | DWORD | 4 | +4 | +4 | コード識別の検証に使用するチェック方法を示すフラグ(SAFER_CRITERIA_*)。 |
| ImagePath | LPWSTR | 8/4 | +8 | +8 | 検証対象の実行可能ファイルのパス。NULL可。 |
| hImageFileHandle | HANDLE | 8/4 | +16 | +12 | 検証対象ファイルへのハンドル。INVALID_HANDLE_VALUE可。 |
| UrlZoneId | DWORD | 4 | +24 | +16 | ファイルの取得元URLゾーンを示すID。 |
| ImageHash | BYTE | 64 | +28 | +20 | イメージのハッシュ値(固定長バッファー)。 |
| dwImageHashSize | DWORD | 4 | +92 | +84 | ImageHashの有効なバイト数。 |
| ImageSize | LONGLONG | 8 | +96 | +88 | イメージのサイズ(バイト)。LONGLONG。 |
| HashAlgorithm | ALG_ID | 4 | +104 | +96 | ハッシュ計算に使用したアルゴリズムID(ALG_ID)。 |
| pByteBlock | BYTE* | 8/4 | +112 | +100 | ハッシュ計算対象のメモリ内コードブロックへのポインター。NULL可。 |
| hWndParent | HWND | 8/4 | +120 | +104 | WinVerifyTrustのUI表示時に使用する親ウィンドウハンドル。 |
| dwWVTUIChoice | DWORD | 4 | +128 | +108 | WinVerifyTrust UIの表示方法を指定する値(WTD_UI_*)。 |
各言語での定義
#include <windows.h>
// SAFER_CODE_PROPERTIES_V1 (x64 136 / x86 112 バイト)
typedef struct SAFER_CODE_PROPERTIES_V1 {
DWORD cbSize;
DWORD dwCheckFlags;
LPWSTR ImagePath;
HANDLE hImageFileHandle;
DWORD UrlZoneId;
BYTE ImageHash[64];
DWORD dwImageHashSize;
LONGLONG ImageSize;
ALG_ID HashAlgorithm;
BYTE* pByteBlock;
HWND hWndParent;
DWORD dwWVTUIChoice;
} SAFER_CODE_PROPERTIES_V1;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SAFER_CODE_PROPERTIES_V1
{
public uint cbSize;
public uint dwCheckFlags;
public IntPtr ImagePath;
public IntPtr hImageFileHandle;
public uint UrlZoneId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public byte[] ImageHash;
public uint dwImageHashSize;
public long ImageSize;
public uint HashAlgorithm;
public IntPtr pByteBlock;
public IntPtr hWndParent;
public uint dwWVTUIChoice;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SAFER_CODE_PROPERTIES_V1
Public cbSize As UInteger
Public dwCheckFlags As UInteger
Public ImagePath As IntPtr
Public hImageFileHandle As IntPtr
Public UrlZoneId As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=64)> Public ImageHash() As Byte
Public dwImageHashSize As UInteger
Public ImageSize As Long
Public HashAlgorithm As UInteger
Public pByteBlock As IntPtr
Public hWndParent As IntPtr
Public dwWVTUIChoice As UInteger
End Structureimport ctypes
from ctypes import wintypes
class SAFER_CODE_PROPERTIES_V1(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("dwCheckFlags", wintypes.DWORD),
("ImagePath", ctypes.c_void_p),
("hImageFileHandle", ctypes.c_void_p),
("UrlZoneId", wintypes.DWORD),
("ImageHash", ctypes.c_ubyte * 64),
("dwImageHashSize", wintypes.DWORD),
("ImageSize", ctypes.c_longlong),
("HashAlgorithm", wintypes.DWORD),
("pByteBlock", ctypes.c_void_p),
("hWndParent", ctypes.c_void_p),
("dwWVTUIChoice", wintypes.DWORD),
]#[repr(C)]
pub struct SAFER_CODE_PROPERTIES_V1 {
pub cbSize: u32,
pub dwCheckFlags: u32,
pub ImagePath: *mut core::ffi::c_void,
pub hImageFileHandle: *mut core::ffi::c_void,
pub UrlZoneId: u32,
pub ImageHash: [u8; 64],
pub dwImageHashSize: u32,
pub ImageSize: i64,
pub HashAlgorithm: u32,
pub pByteBlock: *mut core::ffi::c_void,
pub hWndParent: *mut core::ffi::c_void,
pub dwWVTUIChoice: u32,
}import "golang.org/x/sys/windows"
type SAFER_CODE_PROPERTIES_V1 struct {
cbSize uint32
dwCheckFlags uint32
ImagePath uintptr
hImageFileHandle uintptr
UrlZoneId uint32
ImageHash [64]byte
dwImageHashSize uint32
ImageSize int64
HashAlgorithm uint32
pByteBlock uintptr
hWndParent uintptr
dwWVTUIChoice uint32
}type
SAFER_CODE_PROPERTIES_V1 = record
cbSize: DWORD;
dwCheckFlags: DWORD;
ImagePath: Pointer;
hImageFileHandle: Pointer;
UrlZoneId: DWORD;
ImageHash: array[0..63] of Byte;
dwImageHashSize: DWORD;
ImageSize: Int64;
HashAlgorithm: DWORD;
pByteBlock: Pointer;
hWndParent: Pointer;
dwWVTUIChoice: DWORD;
end;const SAFER_CODE_PROPERTIES_V1 = extern struct {
cbSize: u32,
dwCheckFlags: u32,
ImagePath: ?*anyopaque,
hImageFileHandle: ?*anyopaque,
UrlZoneId: u32,
ImageHash: [64]u8,
dwImageHashSize: u32,
ImageSize: i64,
HashAlgorithm: u32,
pByteBlock: ?*anyopaque,
hWndParent: ?*anyopaque,
dwWVTUIChoice: u32,
};type
SAFER_CODE_PROPERTIES_V1 {.bycopy.} = object
cbSize: uint32
dwCheckFlags: uint32
ImagePath: pointer
hImageFileHandle: pointer
UrlZoneId: uint32
ImageHash: array[64, uint8]
dwImageHashSize: uint32
ImageSize: int64
HashAlgorithm: uint32
pByteBlock: pointer
hWndParent: pointer
dwWVTUIChoice: uint32struct SAFER_CODE_PROPERTIES_V1
{
uint cbSize;
uint dwCheckFlags;
void* ImagePath;
void* hImageFileHandle;
uint UrlZoneId;
ubyte[64] ImageHash;
uint dwImageHashSize;
long ImageSize;
uint HashAlgorithm;
void* pByteBlock;
void* hWndParent;
uint dwWVTUIChoice;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SAFER_CODE_PROPERTIES_V1 サイズ: 112 バイト(x86)
dim st, 28 ; 4byte整数×28(構造体サイズ 112 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwCheckFlags : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; ImagePath : LPWSTR (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; hImageFileHandle : HANDLE (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; UrlZoneId : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; ImageHash : BYTE (+20, 64byte) varptr(st)+20 を基点に操作(64byte:入れ子/配列)
; dwImageHashSize : DWORD (+84, 4byte) st.21 = 値 / 値 = st.21 (lpoke/lpeek も可)
; ImageSize : LONGLONG (+88, 8byte) qpoke st,88,値 / qpeek(st,88) ※IronHSPのみ。3.7/3.8は lpoke st,88,下位 : lpoke st,92,上位
; HashAlgorithm : ALG_ID (+96, 4byte) st.24 = 値 / 値 = st.24 (lpoke/lpeek も可)
; pByteBlock : BYTE* (+100, 4byte) st.25 = 値 / 値 = st.25 (lpoke/lpeek も可)
; hWndParent : HWND (+104, 4byte) st.26 = 値 / 値 = st.26 (lpoke/lpeek も可)
; dwWVTUIChoice : DWORD (+108, 4byte) st.27 = 値 / 値 = st.27 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SAFER_CODE_PROPERTIES_V1 サイズ: 136 バイト(x64)
dim st, 34 ; 4byte整数×34(構造体サイズ 136 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwCheckFlags : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; ImagePath : LPWSTR (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; hImageFileHandle : HANDLE (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; UrlZoneId : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ImageHash : BYTE (+28, 64byte) varptr(st)+28 を基点に操作(64byte:入れ子/配列)
; dwImageHashSize : DWORD (+92, 4byte) st.23 = 値 / 値 = st.23 (lpoke/lpeek も可)
; ImageSize : LONGLONG (+96, 8byte) qpoke st,96,値 / qpeek(st,96) ※IronHSPのみ。3.7/3.8は lpoke st,96,下位 : lpoke st,100,上位
; HashAlgorithm : ALG_ID (+104, 4byte) st.26 = 値 / 値 = st.26 (lpoke/lpeek も可)
; pByteBlock : BYTE* (+112, 8byte) qpoke st,112,値 / qpeek(st,112) ※IronHSPのみ。3.7/3.8は lpoke st,112,下位 : lpoke st,116,上位
; hWndParent : HWND (+120, 8byte) qpoke st,120,値 / qpeek(st,120) ※IronHSPのみ。3.7/3.8は lpoke st,120,下位 : lpoke st,124,上位
; dwWVTUIChoice : DWORD (+128, 4byte) st.32 = 値 / 値 = st.32 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SAFER_CODE_PROPERTIES_V1
#field int cbSize
#field int dwCheckFlags
#field intptr ImagePath
#field intptr hImageFileHandle
#field int UrlZoneId
#field byte ImageHash 64
#field int dwImageHashSize
#field int64 ImageSize
#field int HashAlgorithm
#field intptr pByteBlock
#field intptr hWndParent
#field int dwWVTUIChoice
#endstruct
stdim st, SAFER_CODE_PROPERTIES_V1 ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize