Class MetadataFile

java.lang.Object
net.codecrete.windowsapi.winmd.MetadataFile

public class MetadataFile extends Object
Metadata file.

Metadata files are .winmd files in the Portable Executable (PE) format containing metadata in one of the sections.

This class reads .winmd files and provides access to the different components such as tables, blob and strings.

  • Constructor Details

    • MetadataFile

      public MetadataFile(InputStream inputStream)
      Creates a new instance reading the .winmd contents from the provided input stream.
      Parameters:
      inputStream - input stream providing the .winmd contents
  • Method Details

    • getVersion

      public String getVersion()
      Gets the version string of the .winmd file.
      Returns:
      version
    • getClassLayout

      public ClassLayout getClassLayout(int parent)
      Gets the "ClassLayout" row for the specified parent.
      Parameters:
      parent - parent (TypeDef index)
      Returns:
      class layout
    • getConstant

      public Constant getConstant(int parent)
      Gets the "Constant" row for the specified parent.
      Parameters:
      parent - parent (HasConstant coded index)
      Returns:
      constant
    • getCustomAttributes

      public Iterable<CustomAttribute> getCustomAttributes(int parent)
      Gets the "CustomAttribute" rows for the specified parent
      Parameters:
      parent - (HasCustomAttribute coded index)
      Returns:
      iterable for iterating the "CustomAttribute" rows
    • getFields

      public Iterable<Field> getFields(int typeDefIndex)
      Gets the "Field" rows for the specified type definition.
      Parameters:
      typeDefIndex - typeDef (index into TypeDef table)
      Returns:
      iterable for iterating the "Field" rows
    • getFieldLayout

      public FieldLayout getFieldLayout(int field)
      Gets the "FieldLayout" row for the specified field.
      Parameters:
      field - field (Field index)
      Returns:
      field layout
    • getImplMap

      public ImplMap getImplMap(int memberForwarded)
      Gets the "ImplMap" row for the specified member.
      Parameters:
      memberForwarded - field or method definition (MemberForwarded coded index)
      Returns:
      implementation map, or null if none is found
    • getInterfaceImpl

      public Iterable<InterfaceImpl> getInterfaceImpl(int classIndex)
      Gets the "InterfaceImpl" rows for the specified class.
      Parameters:
      classIndex - type definition (index into TypeDef table)
      Returns:
      iterable for iterating the "InterfaceImpl" rows
    • getMemberRef

      public MemberRef getMemberRef(int index)
      Gets the "MemberRef" row for the specified index.
      Parameters:
      index - row index
      Returns:
      member reference
    • getMethodDef

      public MethodDef getMethodDef(int index)
      Gets the "MethodDef" row with the specified index.
      Parameters:
      index - (MethodDef index)
      Returns:
      method definition entry
    • getMethodDefs

      public Iterable<MethodDef> getMethodDefs(int typeDefIndex)
      Gets the "MethodDef" rows for the specified type definition.
      Parameters:
      typeDefIndex - typeDef (index into TypeDef table)
      Returns:
      iterable for iterating the "MethodDef" rows
    • getModuleRefName

      public int getModuleRefName(int moduleRef)
      Gets the ModuleRef name for the specified index.
      Parameters:
      moduleRef - (ModuleRef index)
      Returns:
      string index
    • getNestedClass

      public NestedClass getNestedClass(int nestedClass)
      Gets the "NestedClass" row for the specified class.
      Parameters:
      nestedClass - nested class (TypeAlias index)
      Returns:
      nested class entry (consisting of nested and enclosing class), or null if none is found
    • getParameters

      public Iterable<Param> getParameters(int methodDefIndex)
      Gets the "Param" rows for the specified method definition.
      Parameters:
      methodDefIndex - methodDef (index into MethodDef table)
      Returns:
      iterable for iterating the "Param" rows
    • getTypeDef

      public TypeDef getTypeDef(int typeDefIndex)
      Gets the "TypeDef" row for the specified index.
      Parameters:
      typeDefIndex - typeDef (index into TypeDef table)
      Returns:
      the type definition
    • getTypeDefs

      public Iterable<TypeDef> getTypeDefs()
      Gets an iterator over the TypeDef table.
      Returns:
      the iterator
    • getTypeDefinitionCount

      public int getTypeDefinitionCount()
      Gets the number of rows in the TypeDef table.
      Returns:
      the number of rows
    • getTypeRef

      public TypeRef getTypeRef(int index)
      Gets the "TypeRef" row for the specified index.
      Parameters:
      index - row index
      Returns:
      type reference
    • getString

      public String getString(int index)
      Gets the string with the specified index from the 'string' heap.
      Parameters:
      index - string index
      Returns:
      string
    • getBlob

      public Blob getBlob(int index)
      Gets the Blob with the specified index from the 'blob' heap.
      Parameters:
      index - blob index
      Returns:
      blob handle