winmd

package
v0.0.0-...-18516e4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package winmd implements a parser for Windows Metadata (WinMD). The reference document is ECMA-335 6th edition, which can be located at https://www.ecma-international.org/wp-content/uploads/ECMA-335_6th_edition_june_2012.pdf.

Documentation and comments referencing an ECMA-335 section are prefixed with the symbol §.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Index

Constants

This section is empty.

Variables

View Source
var (
	TypeDefOrRef_Null     = TypeDefOrRef{-1}
	TypeDefOrRef_TypeDef  = TypeDefOrRef{0}
	TypeDefOrRef_TypeRef  = TypeDefOrRef{1}
	TypeDefOrRef_TypeSpec = TypeDefOrRef{2}
)
View Source
var (
	HasConstant_Null     = HasConstant{-1}
	HasConstant_Field    = HasConstant{0}
	HasConstant_Param    = HasConstant{1}
	HasConstant_Property = HasConstant{2}
)
View Source
var (
	HasFieldMarshal_Null  = HasFieldMarshal{-1}
	HasFieldMarshal_Field = HasFieldMarshal{0}
	HasFieldMarshal_Param = HasFieldMarshal{1}
)
View Source
var (
	HasDeclSecurity_Null      = HasDeclSecurity{-1}
	HasDeclSecurity_TypeDef   = HasDeclSecurity{0}
	HasDeclSecurity_MethodDef = HasDeclSecurity{1}
	HasDeclSecurity_Assembly  = HasDeclSecurity{2}
)
View Source
var (
	MemberRefParent_Null      = MemberRefParent{-1}
	MemberRefParent_TypeDef   = MemberRefParent{0}
	MemberRefParent_TypeRef   = MemberRefParent{1}
	MemberRefParent_ModuleRef = MemberRefParent{2}
	MemberRefParent_MethodDef = MemberRefParent{3}
	MemberRefParent_TypeSpec  = MemberRefParent{4}
)
View Source
var (
	HasSemantics_Null     = HasSemantics{-1}
	HasSemantics_Event    = HasSemantics{0}
	HasSemantics_Property = HasSemantics{1}
)
View Source
var (
	MethodDefOrRef_Null      = MethodDefOrRef{-1}
	MethodDefOrRef_MethodDef = MethodDefOrRef{0}
	MethodDefOrRef_MemberRef = MethodDefOrRef{1}
)
View Source
var (
	MemberForwarded_Null      = MemberForwarded{-1}
	MemberForwarded_Field     = MemberForwarded{0}
	MemberForwarded_MethodDef = MemberForwarded{1}
)
View Source
var (
	Implementation_Null         = Implementation{-1}
	Implementation_File         = Implementation{0}
	Implementation_AssemblyRef  = Implementation{1}
	Implementation_ExportedType = Implementation{2}
)
View Source
var (
	CustomAttributeType_Null      = CustomAttributeType{-1}
	CustomAttributeType_Reserved0 = CustomAttributeType{0}
	CustomAttributeType_Reserved1 = CustomAttributeType{1}
	CustomAttributeType_MethodDef = CustomAttributeType{2}
	CustomAttributeType_MemberRef = CustomAttributeType{3}
	CustomAttributeType_Reserved4 = CustomAttributeType{4}
)
View Source
var (
	ResolutionScope_Null        = ResolutionScope{-1}
	ResolutionScope_Module      = ResolutionScope{0}
	ResolutionScope_ModuleRef   = ResolutionScope{1}
	ResolutionScope_AssemblyRef = ResolutionScope{2}
	ResolutionScope_TypeRef     = ResolutionScope{3}
)
View Source
var (
	TypeOrMethodDef_Null      = TypeOrMethodDef{-1}
	TypeOrMethodDef_TypeDef   = TypeOrMethodDef{0}
	TypeOrMethodDef_MethodDef = TypeOrMethodDef{1}
)
View Source
var (
	HasCustomAttribute_Null                   = HasCustomAttribute{-1}
	HasCustomAttribute_MethodDef              = HasCustomAttribute{0}
	HasCustomAttribute_Field                  = HasCustomAttribute{1}
	HasCustomAttribute_TypeRef                = HasCustomAttribute{2}
	HasCustomAttribute_TypeDef                = HasCustomAttribute{3}
	HasCustomAttribute_Param                  = HasCustomAttribute{4}
	HasCustomAttribute_InterfaceImpl          = HasCustomAttribute{5}
	HasCustomAttribute_MemberRef              = HasCustomAttribute{6}
	HasCustomAttribute_Module                 = HasCustomAttribute{7}
	HasCustomAttribute_None                   = HasCustomAttribute{8}
	HasCustomAttribute_Property               = HasCustomAttribute{9}
	HasCustomAttribute_Event                  = HasCustomAttribute{10}
	HasCustomAttribute_StandAloneSig          = HasCustomAttribute{11}
	HasCustomAttribute_ModuleRef              = HasCustomAttribute{12}
	HasCustomAttribute_TypeSpec               = HasCustomAttribute{13}
	HasCustomAttribute_Assembly               = HasCustomAttribute{14}
	HasCustomAttribute_AssemblyRef            = HasCustomAttribute{15}
	HasCustomAttribute_File                   = HasCustomAttribute{16}
	HasCustomAttribute_ExportedType           = HasCustomAttribute{17}
	HasCustomAttribute_ManifestResource       = HasCustomAttribute{18}
	HasCustomAttribute_GenericParam           = HasCustomAttribute{19}
	HasCustomAttribute_GenericParamConstraint = HasCustomAttribute{20}
	HasCustomAttribute_MethodSpec             = HasCustomAttribute{21}
)
View Source
var (
	TypeDefOrRefOrSpec_Null     = TypeDefOrRefOrSpec{-1}
	TypeDefOrRefOrSpec_TypeDef  = TypeDefOrRefOrSpec{0}
	TypeDefOrRefOrSpec_TypeRef  = TypeDefOrRefOrSpec{1}
	TypeDefOrRefOrSpec_TypeSpec = TypeDefOrRefOrSpec{2}
)

Functions

This section is empty.

Types

type Assembly

type Assembly struct {
	HashAlgID      AssemblyHashAlgorithm
	MajorVersion   uint16
	MinorVersion   uint16
	BuildNumber    uint16
	RevisionNumber uint16
	Flags          AssemblyFlags
	PublicKey      []byte
	Name           String
	Culture        String
}

Assembly is defined in §II.22.2. @table=0x20

type AssemblyFlags

type AssemblyFlags uint32

AssemblyFlags is defined in §II.23.1.2.

const (
	AssemblyFlags_PublicKey                  AssemblyFlags = 0x0001
	AssemblyFlags_Retargetable               AssemblyFlags = 0x0100
	AssemblyFlags_DisableJITcompileOptimizer AssemblyFlags = 0x4000
	AssemblyFlags_EnableJITcompileTracking   AssemblyFlags = 0x8000
)

type AssemblyHashAlgorithm

type AssemblyHashAlgorithm uint32

AssemblyHashAlgorithm is defined in §II.23.1.1.

const (
	AssemblyHashAlgorithm_None AssemblyHashAlgorithm = 0x0000
	AssemblyHashAlgorithm_MD5  AssemblyHashAlgorithm = 0x8003
	AssemblyHashAlgorithm_SHA1 AssemblyHashAlgorithm = 0x8004
)

func (AssemblyHashAlgorithm) String

func (i AssemblyHashAlgorithm) String() string

type AssemblyRef

type AssemblyRef struct {
	MajorVersion     uint16
	MinorVersion     uint16
	BuildNumber      uint16
	RevisionNumber   uint16
	Flags            AssemblyFlags
	PublicKeyOrToken []byte
	Name             String
	Culture          String
	HashValue        []byte
}

AssemblyRef is defined in §II.22.5. @table=0x23

type BlobHeap

type BlobHeap []byte

BlobHeap provides access to the #Blob heap as defined in §II.24.2.4.

func (BlobHeap) Bytes

func (bh BlobHeap) Bytes(start uint32) ([]byte, error)

Bytes extracts data from the blob heap bh at offset start.

type ClassLayout

type ClassLayout struct {
	PackingSize uint16
	ClassSize   uint32
	Parent      Index // @ref=TypeDef
}

ClassLayout is defined in §II.22.8. @table=0x0F

type CodedIndex

type CodedIndex[T CodedTag] struct {
	Index Index
	Tag   T
}

CodedIndex indexes a record on any table.

type Constant

type Constant struct {
	Type    ElementType
	Padding byte // 1-byte padding zero
	Parent  CodedIndex[HasConstant]
	Value   []byte
}

Constant is defined in §II.22.9. @table=0x0B

type CustomAttribute

type CustomAttribute struct {
	Parent CodedIndex[HasCustomAttribute]
	Type   CodedIndex[CustomAttributeType]
	Value  []byte
}

CustomAttribute is defined in §II.22.10. @table=0x0C

type CustomAttributeType

type CustomAttributeType struct {
	// contains filtered or unexported fields
}

type DeclSecurity

type DeclSecurity struct {
	Action        uint16
	Parent        CodedIndex[HasDeclSecurity]
	PermissionSet []byte
}

DeclSecurity is defined in §II.22.11. @table=0x0E

type ElementType

type ElementType uint8

ElementType is defined in §II.23.1.16.

const (
	ElementType_END          ElementType = 0x00
	ElementType_VOID         ElementType = 0x01
	ElementType_BOOLEAN      ElementType = 0x02
	ElementType_CHAR         ElementType = 0x03
	ElementType_I1           ElementType = 0x04
	ElementType_U1           ElementType = 0x05
	ElementType_I2           ElementType = 0x06
	ElementType_U2           ElementType = 0x07
	ElementType_I4           ElementType = 0x08
	ElementType_U4           ElementType = 0x09
	ElementType_I8           ElementType = 0x0a
	ElementType_U8           ElementType = 0x0b
	ElementType_R4           ElementType = 0x0c
	ElementType_R8           ElementType = 0x0d
	ElementType_STRING       ElementType = 0x0e
	ElementType_PTR          ElementType = 0x0f
	ElementType_BYREF        ElementType = 0x10
	ElementType_VALUETYPE    ElementType = 0x11
	ElementType_CLASS        ElementType = 0x12
	ElementType_VAR          ElementType = 0x13
	ElementType_ARRAY        ElementType = 0x14
	ElementType_GENERICINST  ElementType = 0x15
	ElementType_TYPEDBYREF   ElementType = 0x16
	ElementType_I            ElementType = 0x18
	ElementType_U            ElementType = 0x19
	ElementType_FNPTR        ElementType = 0x1b
	ElementType_OBJECT       ElementType = 0x1c
	ElementType_SZARRAY      ElementType = 0x1d
	ElementType_MVAR         ElementType = 0x1e
	ElementType_CMOD_REQD    ElementType = 0x1f
	ElementType_CMOD_OPT     ElementType = 0x20
	ElementType_INTERNAL     ElementType = 0x21
	ElementType_MODIFIER     ElementType = 0x40
	ElementType_SENTINEL     ElementType = 0x41
	ElementType_PINNED       ElementType = 0x45
	ElementType_TYPE         ElementType = 0x50
	ElementType_BOXED_OBJECT ElementType = 0x51
	ElementType_RESERVED     ElementType = 0x52
	ElementType_FIELD        ElementType = 0x53
	ElementType_PROPERTY     ElementType = 0x54
	ElementType_ENUM         ElementType = 0x55
)

func (ElementType) String

func (i ElementType) String() string

type Event

type Event struct {
	EventFlags EventAttributes
	Name       String
	EventType  CodedIndex[TypeDefOrRef]
}

Event is defined in §II.22.13. @table=0x14

type EventAttributes

type EventAttributes uint16

EventAttributes is defined in §II.23.1.4.

const (
	EventAttributes_SpecialName   EventAttributes = 0x0200
	EventAttributes_RTSpecialName EventAttributes = 0x0400
)

type EventMap

type EventMap struct {
	Parent    Index // @ref=TypeDef
	EventList Slice // @ref=Event
}

EventMap is defined in §II.22.12. @table=0x12

type ExportedType

type ExportedType struct {
	Flags          TypeAttributes
	TypeDefID      uint32 // index into a TypeDef table, used as hint only
	Name           String
	Namespace      String
	Implementation CodedIndex[Implementation]
}

ExportedType is defined in §II.22.14. @table=0x27

type Field

type Field struct {
	Flags     FieldAttributes
	Name      String
	Signature SigFieldBlob
}

Field is defined in §II.22.15. @table=0x04

type FieldAttributes

type FieldAttributes uint16

FieldAttributes is defined in §II.23.1.5.

const (
	FieldAttributes_FieldAccessMask    FieldAttributes = 0x0007
	FieldAttributes_CompilerControlled FieldAttributes = 0x0000
	FieldAttributes_Private            FieldAttributes = 0x0001
	FieldAttributes_FamANDAssem        FieldAttributes = 0x0002
	FieldAttributes_Assembly           FieldAttributes = 0x0003
	FieldAttributes_Family             FieldAttributes = 0x0004
	FieldAttributes_FamORAssem         FieldAttributes = 0x0005
	FieldAttributes_Public             FieldAttributes = 0x0006
	FieldAttributes_Static             FieldAttributes = 0x0010
	FieldAttributes_InitOnly           FieldAttributes = 0x0020
	FieldAttributes_Literal            FieldAttributes = 0x0040
	FieldAttributes_NotSerialized      FieldAttributes = 0x0080
	FieldAttributes_SpecialName        FieldAttributes = 0x0200
	FieldAttributes_PInvokeImpl        FieldAttributes = 0x2000
	FieldAttributes_RTSpecialName      FieldAttributes = 0x0400
	FieldAttributes_HasFieldMarshal    FieldAttributes = 0x1000
	FieldAttributes_HasDefault         FieldAttributes = 0x8000
	FieldAttributes_HasFieldRVA        FieldAttributes = 0x0100
)

type FieldLayout

type FieldLayout struct {
	Offset uint32
	Field  Index // @ref=Field
}

FieldLayout is defined in §II.22.16. @table=0x10

type FieldMarshal

type FieldMarshal struct {
	Parent     CodedIndex[HasFieldMarshal]
	NativeType []byte
}

FieldMarshal is defined in §II.22.17. @table=0x0D

type FieldRVA

type FieldRVA struct {
	RVA   uint32
	Field Index // @ref=Field
}

FieldRVA is defined in §II.22.18. @table=0x1D

type File

type File struct {
	Flags     FileAttributes
	Name      String
	HashValue []byte
}

File is defined in §II.22.19. @table=0x26

type FileAttributes

type FileAttributes uint16

FileAttributes is defined in §II.23.1.6.

const (
	FileAttributes_ContainsMetaData   FileAttributes = 0x0000
	FileAttributes_ContainsNoMetaData FileAttributes = 0x0001
)

type GUIDHeap

type GUIDHeap []byte

GUIDHeap provides access to the #GUID heap as defined in §II.24.2.5.

func (GUIDHeap) GUID

func (gh GUIDHeap) GUID(idx uint32) ([16]byte, error)

GUID extracts the GUID from the guid heap gh at idx.

type GenericParam

type GenericParam struct {
	Number uint16
	Flags  GenericParamAttributes
	Owner  CodedIndex[TypeOrMethodDef]
	Name   String
}

GenericParam is defined in §II.22.20. @table=0x2A

type GenericParamAttributes

type GenericParamAttributes uint16

GenericParamAttributes is defined in §II.23.1.7.

const (
	GenericParamAttributes_VarianceMask                   GenericParamAttributes = 0x0003
	GenericParamAttributes_None                           GenericParamAttributes = 0x0000
	GenericParamAttributes_Covariant                      GenericParamAttributes = 0x0001
	GenericParamAttributes_Contravariant                  GenericParamAttributes = 0x0002
	GenericParamAttributes_SpecialConstraintMask          GenericParamAttributes = 0x001C
	GenericParamAttributes_ReferenceTypeConstraint        GenericParamAttributes = 0x0004
	GenericParamAttributes_NotNullableValueTypeConstraint GenericParamAttributes = 0x0008
	GenericParamAttributes_DefaultConstructorConstraint   GenericParamAttributes = 0x0010
)

type GenericParamConstraint

type GenericParamConstraint struct {
	Owner      Index // @ref=GenericParam
	Constraint CodedIndex[TypeDefOrRef]
}

GenericParam is defined in §II.22.21. @table=0x2C

type HasConstant

type HasConstant struct {
	// contains filtered or unexported fields
}

type HasCustomAttribute

type HasCustomAttribute struct {
	// contains filtered or unexported fields
}

type HasDeclSecurity

type HasDeclSecurity struct {
	// contains filtered or unexported fields
}

type HasFieldMarshal

type HasFieldMarshal struct {
	// contains filtered or unexported fields
}

type HasSemantics

type HasSemantics struct {
	// contains filtered or unexported fields
}

type ImplMap

type ImplMap struct {
	MappingFlags    PInvokeAttributes
	MemberForwarded CodedIndex[MemberForwarded]
	ImportName      String
	ImportScope     Index // @ref=ModuleRef
}

ImplMap is defined in §II.22.22. @table=0x1C

type Implementation

type Implementation struct {
	// contains filtered or unexported fields
}

type Index

type Index uint32

Index indexes a record in a table.

type InterfaceImpl

type InterfaceImpl struct {
	Class     Index // @ref=TypeDef
	Interface CodedIndex[TypeDefOrRef]
}

InterfaceImpl is defined in §II.22.23. @table=0x09

type ManifestResource

type ManifestResource struct {
	Offset         uint32
	Flags          ManifestResourceAttributes
	Name           String
	Implementation CodedIndex[Implementation]
}

ManifestResource is defined in §II.22.24. @table=0x28

type ManifestResourceAttributes

type ManifestResourceAttributes uint32

ManifestResourceAttributes is defined in §II.23.1.9.

const (
	ManifestResourceAttributes_VisibilityMask ManifestResourceAttributes = 0x0007
	ManifestResourceAttributes_Public         ManifestResourceAttributes = 0x0001
	ManifestResourceAttributes_Private        ManifestResourceAttributes = 0x0002
)

type MemberForwarded

type MemberForwarded struct {
	// contains filtered or unexported fields
}

type MemberRef

type MemberRef struct {
	Class     CodedIndex[MemberRefParent]
	Name      String
	Signature []byte
}

MemberRef is defined in §II.22.25. @table=0x0A

type MemberRefParent

type MemberRefParent struct {
	// contains filtered or unexported fields
}

type Metadata

type Metadata struct {
	Version string
	Tables  *Tables
	Strings StringHeap
	US      USHeap
	Blob    BlobHeap
	GUID    GUIDHeap
	// contains filtered or unexported fields
}

A Metadata represents an open Windows Metadata file.

func New

func New(pefile *pe.File) (*Metadata, error)

New creates a new Metadata from an underlying PE file. The PE file can be closed after calling New, as the returned Metadata doesn't keep any reference to it.

func Open

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

Open opens a Windows Metadata file at path and returns a Metadata struct that provides access to its contents.

func (*Metadata) FieldSignature

func (m *Metadata) FieldSignature(bytes SigFieldBlob) (SigField, error)

func (*Metadata) MethodDefSignature

func (m *Metadata) MethodDefSignature(data SigMethodDefBlob) (SigMethodDef, error)

type MethodAttributes

type MethodAttributes uint16

MethodAttributes is defined in §II.23.1.10.

const (
	MethodAttributes_MemberAccessMask   MethodAttributes = 0x0007
	MethodAttributes_CompilerControlled MethodAttributes = 0x0000
	MethodAttributes_Private            MethodAttributes = 0x0001
	MethodAttributes_FamANDAssem        MethodAttributes = 0x0002
	MethodAttributes_Assem              MethodAttributes = 0x0003
	MethodAttributes_Family             MethodAttributes = 0x0004
	MethodAttributes_FamORAssem         MethodAttributes = 0x0005
	MethodAttributes_Public             MethodAttributes = 0x0006
	MethodAttributes_Static             MethodAttributes = 0x0010
	MethodAttributes_Final              MethodAttributes = 0x0020
	MethodAttributes_Virtual            MethodAttributes = 0x0040
	MethodAttributes_HideBySig          MethodAttributes = 0x0080
	MethodAttributes_VtableLayoutMask   MethodAttributes = 0x0100
	MethodAttributes_ReuseSlot          MethodAttributes = 0x0000
	MethodAttributes_NewSlot            MethodAttributes = 0x0100
	MethodAttributes_Strict             MethodAttributes = 0x0200
	MethodAttributes_Abstract           MethodAttributes = 0x0400
	MethodAttributes_SpecialName        MethodAttributes = 0x0800
	MethodAttributes_PInvokeImpl        MethodAttributes = 0x2000
	MethodAttributes_UnmanagedExport    MethodAttributes = 0x0008
	MethodAttributes_RTSpecialName      MethodAttributes = 0x1000
	MethodAttributes_HasSecurity        MethodAttributes = 0x4000
	MethodAttributes_RequireSecObject   MethodAttributes = 0x8000
)

type MethodDef

type MethodDef struct {
	RVA       uint32
	ImplFlags MethodImplAttributes
	Flags     MethodAttributes
	Name      String
	Signature SigMethodDefBlob
	ParamList Slice // @ref=Param
}

MethodDef is defined in §II.22.26. @table=0x06

type MethodDefOrRef

type MethodDefOrRef struct {
	// contains filtered or unexported fields
}

type MethodImpl

type MethodImpl struct {
	Class             Index // @ref=TypeDef
	MethodBody        CodedIndex[MethodDefOrRef]
	MethodDeclaration CodedIndex[MethodDefOrRef]
}

MethodImpl is defined in §II.22.27. @table=0x19

type MethodImplAttributes

type MethodImplAttributes uint16

MethodImplAttributes is defined in §II.23.1.11.

const (
	MethodImplAttributes_CodeTypeMask     MethodImplAttributes = 0x0003
	MethodImplAttributes_IL               MethodImplAttributes = 0x0000
	MethodImplAttributes_Native           MethodImplAttributes = 0x0001
	MethodImplAttributes_OPTIL            MethodImplAttributes = 0x0002
	MethodImplAttributes_Runtime          MethodImplAttributes = 0x0003
	MethodImplAttributes_ManagedMask      MethodImplAttributes = 0x0004
	MethodImplAttributes_Unmanaged        MethodImplAttributes = 0x0004
	MethodImplAttributes_Managed          MethodImplAttributes = 0x0000
	MethodImplAttributes_ForwardRef       MethodImplAttributes = 0x0010
	MethodImplAttributes_PreserveSig      MethodImplAttributes = 0x0080
	MethodImplAttributes_InternalCall     MethodImplAttributes = 0x1000
	MethodImplAttributes_Synchronized     MethodImplAttributes = 0x0020
	MethodImplAttributes_NoInlining       MethodImplAttributes = 0x0008
	MethodImplAttributes_MaxMethodImplVal MethodImplAttributes = 0xffff
	MethodImplAttributes_NoOptimization   MethodImplAttributes = 0x0040
)

type MethodSemantics

type MethodSemantics struct {
	Semantics   MethodSemanticsAttributes
	Method      Index // @ref=MethodDef
	Association CodedIndex[HasSemantics]
}

MethodImpl is defined in §II.22.28. @table=0x18

type MethodSemanticsAttributes

type MethodSemanticsAttributes uint16

MethodSemanticsAttributes is defined in §II.23.1.12.

const (
	MethodSemanticsAttributes_Setter   MethodSemanticsAttributes = 0x0001
	MethodSemanticsAttributes_Getter   MethodSemanticsAttributes = 0x0002
	MethodSemanticsAttributes_Other    MethodSemanticsAttributes = 0x0004
	MethodSemanticsAttributes_AddOn    MethodSemanticsAttributes = 0x0008
	MethodSemanticsAttributes_RemoveOn MethodSemanticsAttributes = 0x0010
	MethodSemanticsAttributes_Fire     MethodSemanticsAttributes = 0x0020
)

type MethodSpec

type MethodSpec struct {
	Method        CodedIndex[MethodDefOrRef]
	Instantiation []byte
}

MethodSpec is defined in §II.22.29. @table=0x2B

type Module

type Module struct {
	Generation uint16
	Name       String
	Mvid       [16]byte
	EncID      [16]byte
	EncBaseID  [16]byte
}

Module is defined in §II.22.30. @table=0x00

type ModuleRef

type ModuleRef struct {
	Name String
}

ModuleRef is defined in §II.22.31. @table=0x1A

type NestedClass

type NestedClass struct {
	NestedClass    Index // @ref=TypeDef
	EnclosingClass Index // @ref=TypeDef
}

NestedClass is defined in §II.22.32. @table=0x29

type PInvokeAttributes

type PInvokeAttributes uint16

PInvokeAttributes is defined in §II.23.1.8.

const (
	PInvokeAttributes_NoMangle            PInvokeAttributes = 0x0001
	PInvokeAttributes_CharSetMask         PInvokeAttributes = 0x0006
	PInvokeAttributes_CharSetNotSpec      PInvokeAttributes = 0x0000
	PInvokeAttributes_CharSetAnsi         PInvokeAttributes = 0x0002
	PInvokeAttributes_CharSetUnicode      PInvokeAttributes = 0x0004
	PInvokeAttributes_CharSetAuto         PInvokeAttributes = 0x0006
	PInvokeAttributes_SupportsLastError   PInvokeAttributes = 0x0040
	PInvokeAttributes_CallConvMask        PInvokeAttributes = 0x0700
	PInvokeAttributes_CallConvPlatformapi PInvokeAttributes = 0x0100
	PInvokeAttributes_CallConvCdecl       PInvokeAttributes = 0x0200
	PInvokeAttributes_CallConvStdcall     PInvokeAttributes = 0x0300
	PInvokeAttributes_CallConvThiscall    PInvokeAttributes = 0x0400
	PInvokeAttributes_CallConvFastcall    PInvokeAttributes = 0x0500
)

type Param

type Param struct {
	Flags    ParamAttributes
	Sequence uint16
	Name     String
}

Param is defined in §II.22.33. @table=0x08

type ParamAttributes

type ParamAttributes uint16

ParamAttributes is defined in §II.23.1.13.

const (
	ParamAttributes_In              ParamAttributes = 0x0001
	ParamAttributes_Out             ParamAttributes = 0x0002
	ParamAttributes_Optional        ParamAttributes = 0x0010
	ParamAttributes_HasDefault      ParamAttributes = 0x1000
	ParamAttributes_HasFieldMarshal ParamAttributes = 0x2000
	ParamAttributes_Unused          ParamAttributes = 0xcfe0
)

type Property

type Property struct {
	Flags PropertyAttributes
	Name  String
	Type  SigPropertyBlob
}

Property is defined in §II.22.34. @table=0x17

type PropertyAttributes

type PropertyAttributes uint16

PropertyAttributes is defined in §II.23.1.14.

const (
	PropertyAttributes_SpecialName   PropertyAttributes = 0x0200
	PropertyAttributes_RTSpecialName PropertyAttributes = 0x0400
	PropertyAttributes_HasDefault    PropertyAttributes = 0x1000
	PropertyAttributes_Unused        PropertyAttributes = 0xe9ff
)

type PropertyMap

type PropertyMap struct {
	Parent       Index // @ref=TypeDef
	PropertyList Slice // @ref=Property
}

PropertyMap is defined in §II.22.35. @table=0x15

type ResolutionScope

type ResolutionScope struct {
	// contains filtered or unexported fields
}

type SigArray

type SigArray struct {
	Type        SigType
	Rank        uint32
	Sizes       []uint32
	LowerBounds []int32
}

SigArray is a SigType with an ArrayShape, where ArrayShape is defined in §II.23.2.13.

type SigConstraint

type SigConstraint struct {
	Pinned bool
}

type SigCustomMod

type SigCustomMod struct {
	Kind  SigCustomModKind
	Index CodedIndex[TypeDefOrRefOrSpec]
}

SigCustomMod is defined in §II.23.2.7.

type SigCustomModKind

type SigCustomModKind uint8
const (
	SigCustomModKind_Opt SigCustomModKind = iota
	SigCustomModKind_Reqd
)

type SigField

type SigField struct {
	Type SigType
}

SigField is defined in §II.23.2.4.

type SigFieldBlob

type SigFieldBlob []byte

type SigGenericInst

type SigGenericInst struct {
	Class bool
	Index CodedIndex[TypeDefOrRefOrSpec]
	Type  []SigType
}

type SigLocalVar

type SigLocalVar struct {
	Kind SigLocalVarKind
	Mod  []SigLocalVarMod // empty if Kind is TypedByRef
	Type SigType          // empty if Kind is TypedByRef
}

type SigLocalVarKind

type SigLocalVarKind uint8
const (
	SigLocalVarKind_ByValue SigLocalVarKind = iota
	SigLocalVarKind_ByRef
	SigLocalVarKind_TypedByRef
)

type SigLocalVarMod

type SigLocalVarMod struct {
	Mod        *SigCustomMod
	Constraint SigConstraint
}

type SigLocalVars

type SigLocalVars []SigLocalVar

SigLocalVars is defined as "LocalVarSig" in §II.23.2.6. This type represents the type of all local vars in a method, and the name has been changed for clarity and to make it easier to name "SigLocalVar".

type SigMethodDef

type SigMethodDef struct {
	HasThis      bool
	ExplicitThis bool
	VarArgs      bool
	Generic      uint32
	RetType      SigRetType
	Param        []SigParam
}

SigMethodDef is defined in §II.23.2.1.

type SigMethodDefBlob

type SigMethodDefBlob []byte

type SigMethodRef

type SigMethodRef struct {
	SigMethodDef
	VariableParam []Param
}

SigMethodRef is defined in §II.23.2.2.

type SigMethodSpec

type SigMethodSpec []SigType

SigMethodSpec is defined in §II.23.2.15

type SigParam

type SigParam struct {
	Kind SigParamKind
	Type SigType // empty if Kind is TypedByRef
}

SigParam is defined in §II.23.2.10.

type SigParamKind

type SigParamKind uint8
const (
	SigParamKind_ByValue SigParamKind = iota
	SigParamKind_ByRef
	SigParamKind_TypedByRef
)

type SigProperty

type SigProperty struct {
	HasThis bool
	SigField
	Param []SigParam
}

SigProperty is defined in §II.23.2.5.

type SigPropertyBlob

type SigPropertyBlob []byte

type SigRetType

type SigRetType struct {
	Kind SigRetTypeKind
	Type SigType // empty if Kind is TypedByRef or Void
}

SigRetType is defined in §II.23.2.11.

type SigRetTypeKind

type SigRetTypeKind uint8
const (
	SigRetTypeKind_ByValue SigRetTypeKind = iota
	SigRetTypeKind_ByRef
	SigRetTypeKind_TypedByRef
	SigRetTypeKind_Void
)

type SigType

type SigType struct {
	Kind  ElementType
	Mod   []SigCustomMod
	Value any // optional
}

SigType is defined in §II.23.2.12.

type SigTypeSpec

type SigTypeSpec struct {
	Kind  ElementType
	Value any
}

SigTypeSpec is defined in §II.23.2.14.

type Slice

type Slice struct {
	Start Index
	End   Index
}

Slice indexes the range of records [Start,End) on the table T.

func (Slice) All

func (s Slice) All() iter.Seq[Index]

All returns a sequence of all indices in the slice.

func (Slice) Len

func (s Slice) Len() uint32

Len returns the number of records in the slice.

type StandAloneSig

type StandAloneSig struct {
	Signature []byte
}

StandAloneSig is defined in §II.22.36. @table=0x11

type String

type String struct {
	// Start is the offset in the #Strings heap where the string starts. This is the parameter that
	// was passed to StringHeap.String to create this String. The strings heap doesn't contain
	// duplicate strings, so this value can be used to uniquely identify strings that come from the
	// same heap.
	Start uint32
	// contains filtered or unexported fields
}

String is complete UTF8 string from the #String heap It does not contain the null-terminated character.

It is used as an optimization to avoid allocating when reading from the #Strings heap.

func (String) String

func (s String) String() string

type StringHeap

type StringHeap []byte

StringHeap provides access to #Strings heap as defined in §II.24.2.3.

func (StringHeap) String

func (sh StringHeap) String(start uint32) (String, error)

String extracts string from the string heap st at offset start.

type Table

type Table[T any] struct {
	// contains filtered or unexported fields
}

Table is a record container as defined in §II.22.

func (Table[T]) At

func (t Table[T]) At(row Index) (T, error)

At returns the record at row.

func (Table[T]) Indices

func (t Table[T]) Indices() iter.Seq[Index]

func (Table[T]) Len

func (t Table[T]) Len() uint32

Len returns the number of records in the table.

func (Table[T]) Name

func (t Table[T]) Name() string

Name returns the metadata table name.

type Tables

type Tables struct {
	Assembly               Table[Assembly]
	AssemblyRef            Table[AssemblyRef]
	ClassLayout            Table[ClassLayout]
	Constant               Table[Constant]
	CustomAttribute        Table[CustomAttribute]
	DeclSecurity           Table[DeclSecurity]
	EventMap               Table[EventMap]
	Event                  Table[Event]
	ExportedType           Table[ExportedType]
	Field                  Table[Field]
	FieldLayout            Table[FieldLayout]
	FieldMarshal           Table[FieldMarshal]
	FieldRVA               Table[FieldRVA]
	File                   Table[File]
	GenericParam           Table[GenericParam]
	GenericParamConstraint Table[GenericParamConstraint]
	ImplMap                Table[ImplMap]
	InterfaceImpl          Table[InterfaceImpl]
	ManifestResource       Table[ManifestResource]
	MemberRef              Table[MemberRef]
	MethodDef              Table[MethodDef]
	MethodImpl             Table[MethodImpl]
	MethodSemantics        Table[MethodSemantics]
	MethodSpec             Table[MethodSpec]
	Module                 Table[Module]
	ModuleRef              Table[ModuleRef]
	NestedClass            Table[NestedClass]
	Param                  Table[Param]
	Property               Table[Property]
	PropertyMap            Table[PropertyMap]
	StandAloneSig          Table[StandAloneSig]
	TypeDef                Table[TypeDef]
	TypeRef                Table[TypeRef]
	TypeSpec               Table[TypeSpec]
}

Tables provides access to the tables and records stored in the #~ stream as defined in §II.24.2.6

type TypeAttributes

type TypeAttributes uint32

TypeAttributes is defined in §II.23.1.15.

const (
	TypeAttributes_VisibilityMask         TypeAttributes = 0x00000007
	TypeAttributes_NotPublic              TypeAttributes = 0x00000000
	TypeAttributes_Public                 TypeAttributes = 0x00000001
	TypeAttributes_NestedPublic           TypeAttributes = 0x00000002
	TypeAttributes_NestedPrivate          TypeAttributes = 0x00000003
	TypeAttributes_NestedFamily           TypeAttributes = 0x00000004
	TypeAttributes_NestedAssembly         TypeAttributes = 0x00000005
	TypeAttributes_NestedFamANDAssem      TypeAttributes = 0x00000006
	TypeAttributes_NestedFamORAssem       TypeAttributes = 0x00000007
	TypeAttributes_LayoutMask             TypeAttributes = 0x00000018
	TypeAttributes_AutoLayout             TypeAttributes = 0x00000000
	TypeAttributes_SequentialLayout       TypeAttributes = 0x00000008
	TypeAttributes_ExplicitLayout         TypeAttributes = 0x00000010
	TypeAttributes_ClassSemanticsMask     TypeAttributes = 0x00000020
	TypeAttributes_Class                  TypeAttributes = 0x00000000
	TypeAttributes_Interface              TypeAttributes = 0x00000020
	TypeAttributes_Abstract               TypeAttributes = 0x00000080
	TypeAttributes_Sealed                 TypeAttributes = 0x00000100
	TypeAttributes_SpecialName            TypeAttributes = 0x00000400
	TypeAttributes_Import                 TypeAttributes = 0x00001000
	TypeAttributes_Serializable           TypeAttributes = 0x00002000
	TypeAttributes_StringFormatMask       TypeAttributes = 0x00030000
	TypeAttributes_AnsiClass              TypeAttributes = 0x00000000
	TypeAttributes_UnicodeClass           TypeAttributes = 0x00010000
	TypeAttributes_AutoClass              TypeAttributes = 0x00020000
	TypeAttributes_CustomFormatClass      TypeAttributes = 0x00030000
	TypeAttributes_CustomStringFormatMask TypeAttributes = 0x00C00000
	TypeAttributes_BeforeFieldInit        TypeAttributes = 0x00100000
	TypeAttributes_RTSpecialName          TypeAttributes = 0x00000800
	TypeAttributes_HasSecurity            TypeAttributes = 0x00040000
	TypeAttributes_IsTypeForwarder        TypeAttributes = 0x00200000
)

type TypeDef

type TypeDef struct {
	Flags      TypeAttributes
	Name       String
	Namespace  String
	Extends    CodedIndex[TypeDefOrRef]
	FieldList  Slice // @ref=Field
	MethodList Slice // @ref=MethodDef
}

TypeDef is defined in §II.22.37. @table=0x02

type TypeDefOrRef

type TypeDefOrRef struct {
	// contains filtered or unexported fields
}

type TypeDefOrRefOrSpec

type TypeDefOrRefOrSpec struct {
	// contains filtered or unexported fields
}

type TypeOrMethodDef

type TypeOrMethodDef struct {
	// contains filtered or unexported fields
}

type TypeRef

type TypeRef struct {
	ResolutionScope CodedIndex[ResolutionScope]
	Name            String
	Namespace       String
}

TypeRef is defined in §II.22.38. @table=0x01

type TypeSpec

type TypeSpec struct {
	Signature []byte
}

TypeSpec is defined in §II.22.39. @table=0x1B

type USHeap

type USHeap []byte

USHeap provides access to the #US heap as defined in §II.24.2.4.

Jump to

Keyboard shortcuts

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