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 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.
Generics (GENERICINST/VAR/MVAR signatures and the GenericParam tables) and the event/property tables (Event/EventMap, Property/PropertyMap, MethodSemantics, plus PropertySignature) ARE decoded, for WinRT-style metadata; the Win32/WDK winmds contain none of either (tripwire tests assert this), so that support is inert for those projections.
Example ¶
Example opens a .winmd file, counts its COM interfaces, and decodes the first method signature — the core reader surface.
package main
import (
"fmt"
"log"
"github.com/deploymenttheory/go-winmd"
)
func main() {
file, err := winmd.Open("Windows.Win32.winmd")
if err != nil {
log.Fatal(err)
}
interfaces := 0
for i := range file.Tables.TypeDefs {
if file.Tables.TypeDefs[i].Flags&winmd.TypeAttrInterface != 0 {
interfaces++
}
}
fmt.Printf("%d types, %d COM interfaces\n", len(file.Tables.TypeDefs), interfaces)
if len(file.Tables.Methods) > 0 {
sig, err := file.MethodSignature(file.Tables.Methods[0].Signature)
if err != nil {
log.Fatal(err)
}
fmt.Printf("first method: %d params, return kind %d\n", len(sig.Params), sig.Return.Kind)
}
}
Output:
Index ¶
- func DecodeConstant(elem ElementType, blob []byte) any
- type BlobHeap
- type ClassLayoutRow
- type CodedIndex
- type ConstantRow
- type CustomAttr
- type CustomAttributeRow
- type ElementType
- type EventAttributes
- type EventMapRow
- type EventRow
- type FieldAttributes
- type FieldLayoutRow
- type FieldRow
- type File
- func (f *File) AttributesFor(target CodedIndex) []CustomAttr
- func (f *File) FieldSignature(blobOffset uint32) (TypeSig, error)
- func (f *File) MethodSignature(blobOffset uint32) (MethodSig, error)
- func (f *File) PropertySignature(blobOffset uint32) (MethodSig, error)
- func (f *File) TypeSpecSignature(blobOffset uint32) (TypeSig, error)
- type GUIDHeap
- type GenericParamConstraintRow
- type GenericParamRow
- type ImplMapRow
- type InterfaceImplRow
- type MemberRefRow
- type MethodAttributes
- type MethodDefRow
- type MethodImplAttributes
- type MethodSemanticsAttributes
- type MethodSemanticsRow
- type MethodSig
- type NestedClassRow
- type PInvokeAttributes
- type ParamAttributes
- type ParamRow
- type PropertyAttributes
- type PropertyMapRow
- type PropertyRow
- type StringHeap
- type Table
- type Tables
- type TypeAttributes
- type TypeDefRow
- type TypeRefRow
- type TypeSig
- type TypeSigKind
Examples ¶
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).
type ClassLayoutRow ¶
ClassLayoutRow is a ClassLayout table row (§II.22.8).
type CodedIndex ¶
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 EventAttributes ¶ added in v0.3.0
type EventAttributes uint16
EventAttributes is the Event EventFlags column (§II.23.1.4).
const ( EventAttrSpecialName EventAttributes = 0x0200 EventAttrRTSpecialName EventAttributes = 0x0400 )
func (EventAttributes) String ¶ added in v0.3.0
func (a EventAttributes) String() string
String renders the set attributes in specification vocabulary.
type EventMapRow ¶ added in v0.3.0
type EventMapRow struct {
Parent uint32 // TypeDef row
// EventFirst/EventEnd is a 1-based half-open row range into Events.
EventFirst, EventEnd uint32
}
EventMapRow is an EventMap table row (§II.22.12). Present in WinRT metadata; absent from the Win32/WDK winmds (as are the other four event/property tables below).
type EventRow ¶ added in v0.3.0
type EventRow struct {
EventFlags EventAttributes
Name string
EventType CodedIndex // TypeDefOrRef: the delegate type
}
EventRow is an Event table row (§II.22.13).
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 ¶
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 (*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 ¶
FieldSignature decodes the FieldSig blob (§II.23.2.4) at the given #Blob offset.
func (*File) MethodSignature ¶
MethodSignature decodes the MethodDefSig blob (§II.23.2.1) at the given #Blob offset.
func (*File) PropertySignature ¶ added in v0.3.0
PropertySignature decodes the PropertySig blob (§II.23.2.5) at the given #Blob offset. The shape mirrors MethodDefSig — PROPERTY (0x08, optionally combined with HASTHIS 0x20), ParamCount, the property type, then the indexer parameters — so the property type lands in MethodSig.Return.
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).
type GenericParamConstraintRow ¶ added in v0.2.0
type GenericParamConstraintRow struct {
Owner uint32 // GenericParam row
Constraint CodedIndex // TypeDefOrRef the parameter must satisfy
}
GenericParamConstraintRow is a GenericParamConstraint table row (§II.22.21).
type GenericParamRow ¶ added in v0.2.0
type GenericParamRow struct {
Number uint16 // 0-based position in the owner's parameter list
Flags uint16 // GenericParamAttributes (variance + constraints)
Owner CodedIndex // TypeOrMethodDef: the generic type or method
Name string
}
GenericParamRow is a GenericParam table row (§II.22.20). Present in WinRT and other managed metadata; absent from the Win32/WDK winmds.
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 MethodSemanticsAttributes ¶ added in v0.3.0
type MethodSemanticsAttributes uint16
MethodSemanticsAttributes is the MethodSemantics Semantics column (§II.23.1.12).
const ( MethodSemanticsSetter MethodSemanticsAttributes = 0x0001 // msSetter: put_ MethodSemanticsGetter MethodSemanticsAttributes = 0x0002 // msGetter: get_ MethodSemanticsOther MethodSemanticsAttributes = 0x0004 // msOther MethodSemanticsAddOn MethodSemanticsAttributes = 0x0008 // msAddOn: add_ MethodSemanticsRemoveOn MethodSemanticsAttributes = 0x0010 // msRemoveOn: remove_ MethodSemanticsFire MethodSemanticsAttributes = 0x0020 // msFire )
func (MethodSemanticsAttributes) String ¶ added in v0.3.0
func (a MethodSemanticsAttributes) String() string
String renders the set attributes in specification vocabulary.
type MethodSemanticsRow ¶ added in v0.3.0
type MethodSemanticsRow struct {
Semantics MethodSemanticsAttributes
Method uint32 // MethodDef row
Association CodedIndex // HasSemantics: the Event or Property
}
MethodSemanticsRow is a MethodSemantics table row (§II.22.28): it binds a get_/put_/add_/remove_ method to its owning property or event.
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 PropertyAttributes ¶ added in v0.3.0
type PropertyAttributes uint16
PropertyAttributes is the Property Flags column (§II.23.1.14).
const ( PropertyAttrSpecialName PropertyAttributes = 0x0200 PropertyAttrRTSpecialName PropertyAttributes = 0x0400 PropertyAttrHasDefault PropertyAttributes = 0x1000 )
func (PropertyAttributes) String ¶ added in v0.3.0
func (a PropertyAttributes) String() string
String renders the set attributes in specification vocabulary.
type PropertyMapRow ¶ added in v0.3.0
type PropertyMapRow struct {
Parent uint32 // TypeDef row
// PropertyFirst/PropertyEnd is a 1-based half-open row range into
// Properties.
PropertyFirst, PropertyEnd uint32
}
PropertyMapRow is a PropertyMap table row (§II.22.35).
type PropertyRow ¶ added in v0.3.0
type PropertyRow struct {
Flags PropertyAttributes
Name string
Type uint32 // #Blob offset of the PropertySig (§II.23.2.5)
}
PropertyRow is a Property table row (§II.22.34).
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).
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
EventMaps []EventMapRow
Events []EventRow
PropertyMaps []PropertyMapRow
Properties []PropertyRow
MethodSemantics []MethodSemanticsRow
ModuleRefs []string
TypeSpecs []uint32 // #Blob offsets
ImplMaps []ImplMapRow
NestedClasses []NestedClassRow
GenericParams []GenericParamRow
GenericParamConstraints []GenericParamConstraintRow
// 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 / SigGenericInst: the referenced type. IsValueType records
// whether the token used VALUETYPE (struct/enum) or CLASS.
Namespace string
Name string
IsValueType bool
Child *TypeSig // SigPointer / SigArray / SigSZArray element
ArrayLen uint32 // SigArray fixed length
FuncSig *MethodSig // SigFuncPtr target
// GenericArgs holds the type arguments of a SigGenericInst (e.g. the T
// of IVector`1<T>).
GenericArgs []TypeSig
// GenericIndex is the parameter position of a SigVar/SigMVar (0-based).
GenericIndex uint32
// 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 // Generics (WinRT and other managed metadata; absent from Win32/WDK): SigGenericInst // Namespace/Name is the generic type; GenericArgs the args SigVar // a type generic parameter; GenericIndex is its position SigMVar // a method generic parameter; GenericIndex is its position )