Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › CS_RESOURCE

CS_RESOURCE

構造体
サイズx64: 33 バイト / x86: 33 バイトパッキング1

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

フィールド

フィールドサイズx64x86説明
CS_HeaderCS_DES33+0+0クラス固有リソースの記述子ヘッダ(CS_DES)。

各言語での定義

#include <windows.h>

// CS_DES  (x64 33 / x86 33 バイト)
#pragma pack(push, 1)
typedef struct CS_DES {
    DWORD CSD_SignatureLength;
    DWORD CSD_LegacyDataOffset;
    DWORD CSD_LegacyDataSize;
    DWORD CSD_Flags;
    GUID CSD_ClassGuid;
    BYTE CSD_Signature[1];
} CS_DES;
#pragma pack(pop)

// CS_RESOURCE  (x64 33 / x86 33 バイト)
#pragma pack(push, 1)
typedef struct CS_RESOURCE {
    CS_DES CS_Header;
} CS_RESOURCE;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct CS_DES
{
    public uint CSD_SignatureLength;
    public uint CSD_LegacyDataOffset;
    public uint CSD_LegacyDataSize;
    public uint CSD_Flags;
    public Guid CSD_ClassGuid;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] CSD_Signature;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct CS_RESOURCE
{
    public CS_DES CS_Header;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure CS_DES
    Public CSD_SignatureLength As UInteger
    Public CSD_LegacyDataOffset As UInteger
    Public CSD_LegacyDataSize As UInteger
    Public CSD_Flags As UInteger
    Public CSD_ClassGuid As Guid
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public CSD_Signature() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure CS_RESOURCE
    Public CS_Header As CS_DES
End Structure
import ctypes
from ctypes import wintypes

class CS_DES(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("CSD_SignatureLength", wintypes.DWORD),
        ("CSD_LegacyDataOffset", wintypes.DWORD),
        ("CSD_LegacyDataSize", wintypes.DWORD),
        ("CSD_Flags", wintypes.DWORD),
        ("CSD_ClassGuid", GUID),
        ("CSD_Signature", ctypes.c_ubyte * 1),
    ]

class CS_RESOURCE(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("CS_Header", CS_DES),
    ]
#[repr(C, packed(1))]
pub struct CS_DES {
    pub CSD_SignatureLength: u32,
    pub CSD_LegacyDataOffset: u32,
    pub CSD_LegacyDataSize: u32,
    pub CSD_Flags: u32,
    pub CSD_ClassGuid: GUID,
    pub CSD_Signature: [u8; 1],
}

#[repr(C, packed(1))]
pub struct CS_RESOURCE {
    pub CS_Header: CS_DES,
}
import "golang.org/x/sys/windows"

type CS_DES struct {
	CSD_SignatureLength uint32
	CSD_LegacyDataOffset uint32
	CSD_LegacyDataSize uint32
	CSD_Flags uint32
	CSD_ClassGuid windows.GUID
	CSD_Signature [1]byte
}

type CS_RESOURCE struct {
	CS_Header CS_DES
}
type
  CS_DES = packed record
    CSD_SignatureLength: DWORD;
    CSD_LegacyDataOffset: DWORD;
    CSD_LegacyDataSize: DWORD;
    CSD_Flags: DWORD;
    CSD_ClassGuid: TGUID;
    CSD_Signature: array[0..0] of Byte;
  end;

  CS_RESOURCE = packed record
    CS_Header: CS_DES;
  end;
const CS_DES = extern struct {
    CSD_SignatureLength: u32,
    CSD_LegacyDataOffset: u32,
    CSD_LegacyDataSize: u32,
    CSD_Flags: u32,
    CSD_ClassGuid: GUID,
    CSD_Signature: [1]u8,
};

const CS_RESOURCE = extern struct {
    CS_Header: CS_DES,
};
type
  CS_DES {.packed.} = object
    CSD_SignatureLength: uint32
    CSD_LegacyDataOffset: uint32
    CSD_LegacyDataSize: uint32
    CSD_Flags: uint32
    CSD_ClassGuid: GUID
    CSD_Signature: array[1, uint8]

  CS_RESOURCE {.packed.} = object
    CS_Header: CS_DES
align(1)
struct CS_DES
{
    uint CSD_SignatureLength;
    uint CSD_LegacyDataOffset;
    uint CSD_LegacyDataSize;
    uint CSD_Flags;
    GUID CSD_ClassGuid;
    ubyte[1] CSD_Signature;
}

align(1)
struct CS_RESOURCE
{
    CS_DES CS_Header;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CS_RESOURCE サイズ: 33 バイト(x64)
dim st, 9    ; 4byte整数×9(構造体サイズ 33 / 4 切り上げ)
; CS_Header : CS_DES (+0, 33byte)  varptr(st)+0 を基点に操作(33byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
    #field int Data1
    #field short Data2
    #field short Data3
    #field byte Data4 8
#endstruct

#defstruct global CS_DES, pack=1
    #field int CSD_SignatureLength
    #field int CSD_LegacyDataOffset
    #field int CSD_LegacyDataSize
    #field int CSD_Flags
    #field GUID CSD_ClassGuid
    #field byte CSD_Signature 1
#endstruct

#defstruct global CS_RESOURCE, pack=1
    #field CS_DES CS_Header
#endstruct

stdim st, CS_RESOURCE        ; NSTRUCT 変数を確保