winmd

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 8 Imported by: 0

README

go-winmd

Go Reference CI

A native Go reader for ECMA-335 metadata files (.winmd), aligned with the ECMA-335 6th edition standard. Standard library only — no .NET, no cgo, no dependencies.

This is the shared foundation of the deploymenttheory Windows bindings family: go-bindings-win32, go-bindings-wdk, and (planned) go-bindings-winrt all generate from metadata parsed by this module.

What it does

  • PE container → CLI metadata root → heaps → tables: parses #~ and #- table streams, #Strings/#Blob/#GUID heaps, with every exported symbol carrying its §II.x specification reference.
  • All 45 ECMA-335 tables sized and skipped correctly; the 15 tables the Windows metadata projections need are materialized into typed rows, with typed Table IDs and typed bitmask columns (TypeAttributes, ParamAttributes, PInvokeAttributes, …) in specification vocabulary.
  • Signature blobs (MethodDefSig, FieldSig, §II.23.2) decoded into a recursive TypeSig grammar.
  • Custom-attribute values decoded (§II.23.3) — fixed and named arguments, not just raw blobs — plus Constant-table value decoding. These are the pieces most winmd readers omit.
  • Hardened against hostile input: untrusted lengths and row indices are bounds-checked and allocation-clamped; corrupt files return errors, never panic or over-allocate.

Tested by brute force: every one of the ~318k signatures and ~152k custom attributes in the pinned Windows.Win32.winmd must decode with zero failures (testdata/PROVENANCE.json pins the fixture; it is fetched on demand and sha256-verified).

Usage

import "github.com/deploymenttheory/go-winmd"

file, err := winmd.Open("Windows.Win32.winmd")
if err != nil { /* ... */ }

for i := range file.Tables.TypeDefs {
    td := &file.Tables.TypeDefs[i]
    if td.Flags&winmd.TypeAttrInterface != 0 {
        fmt.Println(td.Namespace, td.Name, "COM interface")
    }
}

sig, err := file.MethodSignature(file.Tables.Methods[0].Signature)
attrs := file.AttributesFor(winmd.CodedIndex{Table: winmd.TableTypeDef, Row: 1})

The nuget subpackage downloads winmd files from NuGet (flat-container API) with provenance records — used by the bindings generators' fetch-metadata commands and by this module's own test fixture.

Non-goals

Deliberately scoped to what the Windows metadata projections need (recorded in the package documentation): no lazy per-row table access, no generic coded-index tag types, no #US heap, no generics signature decoding (yet — it lands here when go-bindings-winrt needs it; the Win32/WDK metadata contains none).

License

MIT.

Documentation

Overview

Package winmd is a native Go reader for ECMA-335 metadata files (.winmd).

It parses the PE container, the CLI metadata root, the metadata heaps (#Strings, #Blob, #GUID), and decodes the metadata tables needed to project the Windows.Win32 API surface. No .NET runtime, no cgo.

Section references marked § cite ECMA-335 6th edition, partition II: §II.22 (metadata tables), §II.23 (blobs, flags, and signatures), §II.24 (metadata physical layout), §II.25 (PE file format).

Non-goals

The reader is deliberately scoped to what the Windows.Win32 projection needs. The following are intentional omissions (evaluated against github.com/microsoft/go-winmd), not oversights:

  • No dependency on microsoft/go-winmd: it has no tagged releases, depends on x/tools, and lacks the custom-attribute value decoding, Constant decoding, and #- stream handling this projection requires.
  • No lazy per-row table access: the consumer scans every row of every materialized table, so eager typed slices are simpler and faster.
  • No per-group coded-index tag types (go-winmd's CodedIndex[T]): coded indices resolve eagerly to a concrete (Table, Row) pair, which is strictly more informative than an encoded tag+index.
  • No table-layout code generation: tableSchemas is the hand-transcribed §II.22 column layout for all 45 tables.
  • No #US heap: user strings are IL plumbing, never referenced by winmd projections.
  • No generics/BYREF/multi-rank-array signature decoding: absent from the Win32 winmd (the brute-force test suites prove it); such constructs fail with a structured error rather than silently mis-decoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeConstant

func DecodeConstant(elem ElementType, blob []byte) any

DecodeConstant decodes a Constant-table value blob by its declared element type (ECMA-335 §II.22.9). Integers widen to int64/uint64; strings decode from UTF-16LE. Returns nil for unsupported types or truncated blobs.

Types

type BlobHeap

type BlobHeap []byte

BlobHeap is the #Blob heap: length-prefixed binary blobs addressed by byte offset (§II.24.2.4).

func (BlobHeap) Get

func (h BlobHeap) Get(offset uint32) []byte

Get returns the blob at the given heap offset (without its length prefix).

type ClassLayoutRow

type ClassLayoutRow struct {
	PackingSize uint16
	ClassSize   uint32
	Parent      uint32 // TypeDef row
}

ClassLayoutRow is a ClassLayout table row (§II.22.8).

type CodedIndex

type CodedIndex struct {
	Table Table
	Row   uint32
}

CodedIndex is a resolved coded index (§II.24.2.6): a (table, 1-based row) pair. A zero Row means null; Table is TableNull in that case.

func (CodedIndex) IsNull

func (c CodedIndex) IsNull() bool

IsNull reports whether the coded index refers to nothing.

type ConstantRow

type ConstantRow struct {
	Type   ElementType // ELEMENT_TYPE_* of the value (padded to 2 bytes on disk)
	Parent CodedIndex
	Value  uint32 // #Blob offset
}

ConstantRow is a Constant table row (§II.22.9).

type CustomAttr

type CustomAttr struct {
	Namespace string
	Name      string // e.g. "SupportedArchitectureAttribute"
	Fixed     []any
	Named     map[string]any
}

CustomAttr is a decoded custom attribute: the attribute type's name plus its constructor (fixed) and named arguments (ECMA-335 §II.23.3).

Argument values are one of: string, bool, byte, int8, uint16, int16, uint32, int32, uint64, int64, float32, float64, or []any (SZARRAY). Enum-typed arguments decode as int32 (every enum used by the Win32 metadata attribute set is int32-backed).

type CustomAttributeRow

type CustomAttributeRow struct {
	Parent CodedIndex
	Type   CodedIndex // MethodDef or MemberRef of the .ctor
	Value  uint32     // #Blob offset
}

CustomAttributeRow is a CustomAttribute table row (§II.22.10).

type ElementType

type ElementType byte

ElementType is an ELEMENT_TYPE_* constant (§II.23.1.16). The Go names are idiomatic; each constant's comment carries the specification name.

const (
	ElemEnd         ElementType = 0x00 // ELEMENT_TYPE_END
	ElemVoid        ElementType = 0x01 // ELEMENT_TYPE_VOID
	ElemBoolean     ElementType = 0x02 // ELEMENT_TYPE_BOOLEAN
	ElemChar        ElementType = 0x03 // ELEMENT_TYPE_CHAR
	ElemInt8        ElementType = 0x04 // ELEMENT_TYPE_I1
	ElemUInt8       ElementType = 0x05 // ELEMENT_TYPE_U1
	ElemInt16       ElementType = 0x06 // ELEMENT_TYPE_I2
	ElemUInt16      ElementType = 0x07 // ELEMENT_TYPE_U2
	ElemInt32       ElementType = 0x08 // ELEMENT_TYPE_I4
	ElemUInt32      ElementType = 0x09 // ELEMENT_TYPE_U4
	ElemInt64       ElementType = 0x0A // ELEMENT_TYPE_I8
	ElemUInt64      ElementType = 0x0B // ELEMENT_TYPE_U8
	ElemFloat32     ElementType = 0x0C // ELEMENT_TYPE_R4
	ElemFloat64     ElementType = 0x0D // ELEMENT_TYPE_R8
	ElemString      ElementType = 0x0E // ELEMENT_TYPE_STRING
	ElemPtr         ElementType = 0x0F // ELEMENT_TYPE_PTR
	ElemByRef       ElementType = 0x10 // ELEMENT_TYPE_BYREF
	ElemValueType   ElementType = 0x11 // ELEMENT_TYPE_VALUETYPE
	ElemClass       ElementType = 0x12 // ELEMENT_TYPE_CLASS
	ElemVar         ElementType = 0x13 // ELEMENT_TYPE_VAR
	ElemArray       ElementType = 0x14 // ELEMENT_TYPE_ARRAY
	ElemGenericInst ElementType = 0x15 // ELEMENT_TYPE_GENERICINST
	ElemTypedByRef  ElementType = 0x16 // ELEMENT_TYPE_TYPEDBYREF
	ElemIntPtr      ElementType = 0x18 // ELEMENT_TYPE_I
	ElemUIntPtr     ElementType = 0x19 // ELEMENT_TYPE_U
	ElemFnPtr       ElementType = 0x1B // ELEMENT_TYPE_FNPTR
	ElemObject      ElementType = 0x1C // ELEMENT_TYPE_OBJECT
	ElemSZArray     ElementType = 0x1D // ELEMENT_TYPE_SZARRAY
	ElemMVar        ElementType = 0x1E // ELEMENT_TYPE_MVAR
	ElemCModReqd    ElementType = 0x1F // ELEMENT_TYPE_CMOD_REQD
	ElemCModOpt     ElementType = 0x20 // ELEMENT_TYPE_CMOD_OPT
	ElemSentinel    ElementType = 0x41 // ELEMENT_TYPE_SENTINEL
)

type FieldAttributes

type FieldAttributes uint16

FieldAttributes is the Field Flags column (§II.23.1.5).

const (
	// Accessibility (mask 0x0007).
	FieldAttrFieldAccessMask    FieldAttributes = 0x0007
	FieldAttrCompilerControlled FieldAttributes = 0x0000
	FieldAttrPrivate            FieldAttributes = 0x0001
	FieldAttrFamANDAssem        FieldAttributes = 0x0002
	FieldAttrAssembly           FieldAttributes = 0x0003
	FieldAttrFamily             FieldAttributes = 0x0004
	FieldAttrFamORAssem         FieldAttributes = 0x0005
	FieldAttrPublic             FieldAttributes = 0x0006

	FieldAttrStatic          FieldAttributes = 0x0010
	FieldAttrInitOnly        FieldAttributes = 0x0020
	FieldAttrLiteral         FieldAttributes = 0x0040
	FieldAttrNotSerialized   FieldAttributes = 0x0080
	FieldAttrHasFieldRVA     FieldAttributes = 0x0100
	FieldAttrSpecialName     FieldAttributes = 0x0200
	FieldAttrRTSpecialName   FieldAttributes = 0x0400
	FieldAttrHasFieldMarshal FieldAttributes = 0x1000
	FieldAttrPInvokeImpl     FieldAttributes = 0x2000
	FieldAttrHasDefault      FieldAttributes = 0x8000
)

func (FieldAttributes) String

func (a FieldAttributes) String() string

String renders the set attributes in specification vocabulary.

type FieldLayoutRow

type FieldLayoutRow struct {
	Offset uint32
	Field  uint32 // Field row
}

FieldLayoutRow is a FieldLayout table row (§II.22.16).

type FieldRow

type FieldRow struct {
	Flags     FieldAttributes
	Name      string
	Signature uint32 // #Blob offset
}

FieldRow is a Field table row (§II.22.15).

type File

type File struct {
	// Version is the metadata version string from the metadata root
	// (e.g. "v4.0.30319").
	Version string

	Strings StringHeap
	Blobs   BlobHeap
	GUIDs   GUIDHeap

	Tables Tables
	// contains filtered or unexported fields
}

File is a parsed .winmd metadata file.

func Open

func Open(path string) (*File, error)

Open reads and parses the .winmd file at path.

func Parse

func Parse(data []byte) (*File, error)

Parse parses an in-memory .winmd (PE) image.

func (*File) AttributesFor

func (f *File) AttributesFor(target CodedIndex) []CustomAttr

AttributesFor returns the decoded custom attributes attached to the given metadata element. Attributes whose blobs fail to decode are skipped.

func (*File) FieldSignature

func (f *File) FieldSignature(blobOffset uint32) (TypeSig, error)

FieldSignature decodes the FieldSig blob (§II.23.2.4) at the given #Blob offset.

func (*File) MethodSignature

func (f *File) MethodSignature(blobOffset uint32) (MethodSig, error)

MethodSignature decodes the MethodDefSig blob (§II.23.2.1) at the given #Blob offset.

type GUIDHeap

type GUIDHeap []byte

GUIDHeap is the #GUID heap: a sequence of 16-byte GUIDs addressed by 1-based index (§II.24.2.5).

func (GUIDHeap) Get

func (h GUIDHeap) Get(index uint32) string

Get returns the GUID at the given 1-based index in canonical "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" form, or "" for index 0.

type ImplMapRow

type ImplMapRow struct {
	MappingFlags    PInvokeAttributes
	MemberForwarded CodedIndex
	ImportName      string
	ImportScope     uint32 // ModuleRef row
}

ImplMapRow is an ImplMap table row (§II.22.22).

type InterfaceImplRow

type InterfaceImplRow struct {
	Class     uint32 // TypeDef row
	Interface CodedIndex
}

InterfaceImplRow is an InterfaceImpl table row (§II.22.23).

type MemberRefRow

type MemberRefRow struct {
	Class     CodedIndex
	Name      string
	Signature uint32 // #Blob offset
}

MemberRefRow is a MemberRef table row (§II.22.25).

type MethodAttributes

type MethodAttributes uint16

MethodAttributes is the MethodDef Flags column (§II.23.1.10).

const (
	// Accessibility (mask 0x0007).
	MethodAttrMemberAccessMask   MethodAttributes = 0x0007
	MethodAttrCompilerControlled MethodAttributes = 0x0000
	MethodAttrPrivate            MethodAttributes = 0x0001
	MethodAttrFamANDAssem        MethodAttributes = 0x0002
	MethodAttrAssem              MethodAttributes = 0x0003
	MethodAttrFamily             MethodAttributes = 0x0004
	MethodAttrFamORAssem         MethodAttributes = 0x0005
	MethodAttrPublic             MethodAttributes = 0x0006

	MethodAttrUnmanagedExport MethodAttributes = 0x0008
	MethodAttrStatic          MethodAttributes = 0x0010
	MethodAttrFinal           MethodAttributes = 0x0020
	MethodAttrVirtual         MethodAttributes = 0x0040
	MethodAttrHideBySig       MethodAttributes = 0x0080

	// Vtable layout (mask 0x0100).
	MethodAttrVtableLayoutMask MethodAttributes = 0x0100
	MethodAttrReuseSlot        MethodAttributes = 0x0000
	MethodAttrNewSlot          MethodAttributes = 0x0100

	MethodAttrStrict           MethodAttributes = 0x0200
	MethodAttrAbstract         MethodAttributes = 0x0400
	MethodAttrSpecialName      MethodAttributes = 0x0800
	MethodAttrRTSpecialName    MethodAttributes = 0x1000
	MethodAttrPInvokeImpl      MethodAttributes = 0x2000
	MethodAttrHasSecurity      MethodAttributes = 0x4000
	MethodAttrRequireSecObject MethodAttributes = 0x8000
)

func (MethodAttributes) String

func (a MethodAttributes) String() string

String renders the set attributes in specification vocabulary.

type MethodDefRow

type MethodDefRow struct {
	RVA       uint32
	ImplFlags MethodImplAttributes
	Flags     MethodAttributes
	Name      string
	Signature uint32 // #Blob offset
	// ParamFirst/ParamEnd is a 1-based half-open row range into Params.
	ParamFirst, ParamEnd uint32
}

MethodDefRow is a MethodDef table row (§II.22.26).

type MethodImplAttributes

type MethodImplAttributes uint16

MethodImplAttributes is the MethodDef ImplFlags column (§II.23.1.11).

const (
	// Code type (mask 0x0003).
	MethodImplAttrCodeTypeMask MethodImplAttributes = 0x0003
	MethodImplAttrIL           MethodImplAttributes = 0x0000
	MethodImplAttrNative       MethodImplAttributes = 0x0001
	MethodImplAttrOPTIL        MethodImplAttributes = 0x0002
	MethodImplAttrRuntime      MethodImplAttributes = 0x0003

	// Managed (mask 0x0004).
	MethodImplAttrManagedMask MethodImplAttributes = 0x0004
	MethodImplAttrManaged     MethodImplAttributes = 0x0000
	MethodImplAttrUnmanaged   MethodImplAttributes = 0x0004

	MethodImplAttrNoInlining     MethodImplAttributes = 0x0008
	MethodImplAttrForwardRef     MethodImplAttributes = 0x0010
	MethodImplAttrSynchronized   MethodImplAttributes = 0x0020
	MethodImplAttrNoOptimization MethodImplAttributes = 0x0040
	MethodImplAttrPreserveSig    MethodImplAttributes = 0x0080
	MethodImplAttrInternalCall   MethodImplAttributes = 0x1000
)

func (MethodImplAttributes) String

func (a MethodImplAttributes) String() string

String renders the set attributes in specification vocabulary.

type MethodSig

type MethodSig struct {
	HasThis bool
	Return  TypeSig
	Params  []TypeSig
}

MethodSig is a decoded MethodDefSig (§II.23.2.1).

type NestedClassRow

type NestedClassRow struct {
	NestedClass    uint32 // TypeDef row
	EnclosingClass uint32 // TypeDef row
}

NestedClassRow is a NestedClass table row (§II.22.32).

type PInvokeAttributes

type PInvokeAttributes uint16

PInvokeAttributes is the ImplMap MappingFlags column (§II.23.1.8).

const (
	PInvokeAttrNoMangle PInvokeAttributes = 0x0001

	// Character set (mask 0x0006).
	PInvokeAttrCharSetMask    PInvokeAttributes = 0x0006
	PInvokeAttrCharSetNotSpec PInvokeAttributes = 0x0000
	PInvokeAttrCharSetAnsi    PInvokeAttributes = 0x0002
	PInvokeAttrCharSetUnicode PInvokeAttributes = 0x0004
	PInvokeAttrCharSetAuto    PInvokeAttributes = 0x0006

	PInvokeAttrSupportsLastError PInvokeAttributes = 0x0040

	// Calling convention (mask 0x0700).
	PInvokeAttrCallConvMask        PInvokeAttributes = 0x0700
	PInvokeAttrCallConvPlatformapi PInvokeAttributes = 0x0100
	PInvokeAttrCallConvCdecl       PInvokeAttributes = 0x0200
	PInvokeAttrCallConvStdcall     PInvokeAttributes = 0x0300
	PInvokeAttrCallConvThiscall    PInvokeAttributes = 0x0400
	PInvokeAttrCallConvFastcall    PInvokeAttributes = 0x0500
)

func (PInvokeAttributes) String

func (a PInvokeAttributes) String() string

String renders the set attributes in specification vocabulary.

type ParamAttributes

type ParamAttributes uint16

ParamAttributes is the Param Flags column (§II.23.1.13).

const (
	ParamAttrIn              ParamAttributes = 0x0001
	ParamAttrOut             ParamAttributes = 0x0002
	ParamAttrOptional        ParamAttributes = 0x0010
	ParamAttrHasDefault      ParamAttributes = 0x1000
	ParamAttrHasFieldMarshal ParamAttributes = 0x2000
)

func (ParamAttributes) String

func (a ParamAttributes) String() string

String renders the set attributes in specification vocabulary.

type ParamRow

type ParamRow struct {
	Flags    ParamAttributes
	Sequence uint16
	Name     string
}

ParamRow is a Param table row (§II.22.33).

type StringHeap

type StringHeap []byte

StringHeap is the #Strings heap: UTF-8, NUL-terminated strings addressed by byte offset (§II.24.2.3).

func (StringHeap) Get

func (h StringHeap) Get(offset uint32) string

Get returns the string at the given heap offset.

type Table

type Table uint8

Table identifies an ECMA-335 metadata table (§II.22).

const (
	TableModule                 Table = 0x00 // §II.22.30
	TableTypeRef                Table = 0x01 // §II.22.38
	TableTypeDef                Table = 0x02 // §II.22.37
	TableFieldPtr               Table = 0x03 // §II.24.2.6 (#- indirection)
	TableField                  Table = 0x04 // §II.22.15
	TableMethodPtr              Table = 0x05 // §II.24.2.6 (#- indirection)
	TableMethodDef              Table = 0x06 // §II.22.26
	TableParamPtr               Table = 0x07 // §II.24.2.6 (#- indirection)
	TableParam                  Table = 0x08 // §II.22.33
	TableInterfaceImpl          Table = 0x09 // §II.22.23
	TableMemberRef              Table = 0x0A // §II.22.25
	TableConstant               Table = 0x0B // §II.22.9
	TableCustomAttribute        Table = 0x0C // §II.22.10
	TableFieldMarshal           Table = 0x0D // §II.22.17
	TableDeclSecurity           Table = 0x0E // §II.22.11
	TableClassLayout            Table = 0x0F // §II.22.8
	TableFieldLayout            Table = 0x10 // §II.22.16
	TableStandAloneSig          Table = 0x11 // §II.22.36
	TableEventMap               Table = 0x12 // §II.22.12
	TableEventPtr               Table = 0x13 // §II.24.2.6 (#- indirection)
	TableEvent                  Table = 0x14 // §II.22.13
	TablePropertyMap            Table = 0x15 // §II.22.35
	TablePropertyPtr            Table = 0x16 // §II.24.2.6 (#- indirection)
	TableProperty               Table = 0x17 // §II.22.34
	TableMethodSemantics        Table = 0x18 // §II.22.28
	TableMethodImpl             Table = 0x19 // §II.22.27
	TableModuleRef              Table = 0x1A // §II.22.31
	TableTypeSpec               Table = 0x1B // §II.22.39
	TableImplMap                Table = 0x1C // §II.22.22
	TableFieldRVA               Table = 0x1D // §II.22.18
	TableAssembly               Table = 0x20 // §II.22.2
	TableAssemblyProcessor      Table = 0x21 // §II.22.4
	TableAssemblyOS             Table = 0x22 // §II.22.3
	TableAssemblyRef            Table = 0x23 // §II.22.5
	TableAssemblyRefProcessor   Table = 0x24 // §II.22.7
	TableAssemblyRefOS          Table = 0x25 // §II.22.6
	TableFile                   Table = 0x26 // §II.22.19
	TableExportedType           Table = 0x27 // §II.22.14
	TableManifestResource       Table = 0x28 // §II.22.24
	TableNestedClass            Table = 0x29 // §II.22.32
	TableGenericParam           Table = 0x2A // §II.22.20
	TableMethodSpec             Table = 0x2B // §II.22.29
	TableGenericParamConstraint Table = 0x2C // §II.22.21

	// TableNull marks a null coded-index target.
	TableNull Table = 0xFF
)

Table IDs in specification order and naming (§II.22).

func (Table) String

func (t Table) String() string

String returns the specification name of the table (§II.22).

type Tables

type Tables struct {
	TypeRefs         []TypeRefRow
	TypeDefs         []TypeDefRow
	Fields           []FieldRow
	Methods          []MethodDefRow
	Params           []ParamRow
	InterfaceImpls   []InterfaceImplRow
	MemberRefs       []MemberRefRow
	Constants        []ConstantRow
	CustomAttributes []CustomAttributeRow
	ClassLayouts     []ClassLayoutRow
	FieldLayouts     []FieldLayoutRow
	ModuleRefs       []string
	TypeSpecs        []uint32 // #Blob offsets
	ImplMaps         []ImplMapRow
	NestedClasses    []NestedClassRow
	// contains filtered or unexported fields
}

Tables holds the decoded metadata tables.

type TypeAttributes

type TypeAttributes uint32

TypeAttributes is the TypeDef Flags column (§II.23.1.15).

const (
	// Visibility (mask 0x00000007).
	TypeAttrVisibilityMask    TypeAttributes = 0x00000007
	TypeAttrNotPublic         TypeAttributes = 0x00000000
	TypeAttrPublic            TypeAttributes = 0x00000001
	TypeAttrNestedPublic      TypeAttributes = 0x00000002
	TypeAttrNestedPrivate     TypeAttributes = 0x00000003
	TypeAttrNestedFamily      TypeAttributes = 0x00000004
	TypeAttrNestedAssembly    TypeAttributes = 0x00000005
	TypeAttrNestedFamANDAssem TypeAttributes = 0x00000006
	TypeAttrNestedFamORAssem  TypeAttributes = 0x00000007

	// Class layout (mask 0x00000018).
	TypeAttrLayoutMask       TypeAttributes = 0x00000018
	TypeAttrAutoLayout       TypeAttributes = 0x00000000
	TypeAttrSequentialLayout TypeAttributes = 0x00000008
	TypeAttrExplicitLayout   TypeAttributes = 0x00000010

	// Class semantics (mask 0x00000020).
	TypeAttrClassSemanticsMask TypeAttributes = 0x00000020
	TypeAttrClass              TypeAttributes = 0x00000000
	TypeAttrInterface          TypeAttributes = 0x00000020

	TypeAttrAbstract       TypeAttributes = 0x00000080
	TypeAttrSealed         TypeAttributes = 0x00000100
	TypeAttrSpecialName    TypeAttributes = 0x00000400
	TypeAttrRTSpecialName  TypeAttributes = 0x00000800
	TypeAttrImport         TypeAttributes = 0x00001000
	TypeAttrSerializable   TypeAttributes = 0x00002000
	TypeAttrWindowsRuntime TypeAttributes = 0x00004000

	// String formatting for native interop (mask 0x00030000).
	TypeAttrStringFormatMask  TypeAttributes = 0x00030000
	TypeAttrAnsiClass         TypeAttributes = 0x00000000
	TypeAttrUnicodeClass      TypeAttributes = 0x00010000
	TypeAttrAutoClass         TypeAttributes = 0x00020000
	TypeAttrCustomFormatClass TypeAttributes = 0x00030000

	TypeAttrHasSecurity     TypeAttributes = 0x00040000
	TypeAttrBeforeFieldInit TypeAttributes = 0x00100000
	TypeAttrIsTypeForwarder TypeAttributes = 0x00200000
)

func (TypeAttributes) String

func (a TypeAttributes) String() string

String renders the set attributes in specification vocabulary.

type TypeDefRow

type TypeDefRow struct {
	Flags     TypeAttributes
	Name      string
	Namespace string
	Extends   CodedIndex
	// FieldFirst/FieldEnd and MethodFirst/MethodEnd are 1-based half-open
	// row ranges into Fields and Methods.
	FieldFirst, FieldEnd   uint32
	MethodFirst, MethodEnd uint32
}

TypeDefRow is a TypeDef table row (§II.22.37).

type TypeRefRow

type TypeRefRow struct {
	ResolutionScope CodedIndex
	Name            string
	Namespace       string
}

TypeRefRow is a TypeRef table row (§II.22.38).

type TypeSig

type TypeSig struct {
	Kind      TypeSigKind
	Primitive ElementType // SigPrimitive

	// SigNamed: the referenced type. IsValueType records whether the token
	// used VALUETYPE (struct/enum) or CLASS (COM interface, Attribute, …).
	Namespace   string
	Name        string
	IsValueType bool

	Child    *TypeSig // SigPointer / SigArray / SigSZArray element
	ArrayLen uint32   // SigArray fixed length

	FuncSig *MethodSig // SigFuncPtr target

	// IsConst is set when the signature carried a modreq/modopt of
	// System.Runtime.CompilerServices.IsConst.
	IsConst bool
}

TypeSig is the decoded, recursive form of an ECMA-335 Type production (§II.23.2.12) — the native structured analogue of the win32json Kind/Child type grammar.

type TypeSigKind

type TypeSigKind uint8

TypeSigKind discriminates TypeSig.

const (
	SigPrimitive TypeSigKind = iota // Primitive holds the element type
	SigNamed                        // Namespace/Name refer to a TypeDef/TypeRef
	SigPointer                      // Child is the pointee
	SigArray                        // Child is the element, ArrayLen the fixed size
	SigSZArray                      // Child is the element (no fixed size)
	SigFuncPtr                      // FuncSig holds the target signature
)

Directories

Path Synopsis
Package nuget downloads winmd files from NuGet packages via the flat-container API.
Package nuget downloads winmd files from NuGet packages via the flat-container API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL