Win32 API 日本語リファレンス
ホームSystem.WinRT.Metadata › COR_NATIVE_LINK

COR_NATIVE_LINK

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

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

フィールド

フィールドサイズx64x86説明
m_linkTypeBYTE1+0+0ネイティブリンクの種別を示すバイト値(P/Invokeのリンク方式)。
m_flagsBYTE1+1+1リンクの追加属性を示すフラグバイト。
m_entryPointDWORD4+2+2エントリポイント名を示す文字列のメタデータトークン。

各言語での定義

#include <windows.h>

// COR_NATIVE_LINK  (x64 6 / x86 6 バイト)
#pragma pack(push, 1)
typedef struct COR_NATIVE_LINK {
    BYTE m_linkType;
    BYTE m_flags;
    DWORD m_entryPoint;
} COR_NATIVE_LINK;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct COR_NATIVE_LINK
{
    public byte m_linkType;
    public byte m_flags;
    public uint m_entryPoint;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure COR_NATIVE_LINK
    Public m_linkType As Byte
    Public m_flags As Byte
    Public m_entryPoint As UInteger
End Structure
import ctypes
from ctypes import wintypes

class COR_NATIVE_LINK(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("m_linkType", ctypes.c_ubyte),
        ("m_flags", ctypes.c_ubyte),
        ("m_entryPoint", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct COR_NATIVE_LINK {
    pub m_linkType: u8,
    pub m_flags: u8,
    pub m_entryPoint: u32,
}
import "golang.org/x/sys/windows"

type COR_NATIVE_LINK struct {
	m_linkType byte
	m_flags byte
	m_entryPoint uint32
}
type
  COR_NATIVE_LINK = packed record
    m_linkType: Byte;
    m_flags: Byte;
    m_entryPoint: DWORD;
  end;
const COR_NATIVE_LINK = extern struct {
    m_linkType: u8,
    m_flags: u8,
    m_entryPoint: u32,
};
type
  COR_NATIVE_LINK {.packed.} = object
    m_linkType: uint8
    m_flags: uint8
    m_entryPoint: uint32
align(1)
struct COR_NATIVE_LINK
{
    ubyte m_linkType;
    ubyte m_flags;
    uint m_entryPoint;
}

HSP用 定義

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

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

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