Use latest dnlib

This commit is contained in:
de4dot 2018-03-11 14:34:07 +01:00
parent 33a4389fce
commit 09ab45158f
69 changed files with 1099 additions and 907 deletions

View File

@ -47,10 +47,10 @@ namespace MakeEverythingPublic {
const string ROSLYN_OPEN_SOURCE_PUBLIC_KEY = "002400000480000094000000060200000024000052534131000400000100010055e0217eb635f69281051f9a823e0c7edd90f28063eb6c7a742a19b4f6139778ee0af438f47aed3b6e9f99838aa8dba689c7a71ddb860c96d923830b57bbd5cd6119406ddb9b002cf1c723bf272d6acbb7129e9d6dd5a5309c94e0ff4b2c884d45a55f475cd7dba59198086f61f5a8c8b5e601c0edbf269733f6f578fc8579c2";
readonly byte[] data;
readonly IMetaData md;
readonly Metadata md;
readonly byte[] ivtBlob;
public IVTPatcher(byte[] data, IMetaData md, byte[] ivtBlob) {
public IVTPatcher(byte[] data, Metadata md, byte[] ivtBlob) {
this.data = data;
this.md = md;
this.ivtBlob = ivtBlob;
@ -58,7 +58,7 @@ namespace MakeEverythingPublic {
public IVTPatcherResult Patch() {
var rids = md.GetCustomAttributeRidList(Table.Assembly, 1);
if (rids.Length == 0)
if (rids.Count == 0)
return IVTPatcherResult.NoCustomAttributes;
if (FindIVT(rids, out var foundIVT, out uint ivtBlobOffset)) {
@ -141,8 +141,7 @@ namespace MakeEverythingPublic {
return IsIVT_TypeDef(declTypeDefToken);
case Table.MemberRef:
var memberRefRow = md.TablesStream.ReadMemberRefRow(ctor.Rid);
if (memberRefRow == null)
if (!md.TablesStream.TryReadMemberRefRow(ctor.Rid, out var memberRefRow))
return false;
if (!CodedToken.MemberRefParent.Decode(memberRefRow.Class, out MDToken parentToken))
return false;
@ -164,8 +163,7 @@ namespace MakeEverythingPublic {
}
bool IsIVT_TypeRef(uint typeRefRid) {
var typeRefRow = md.TablesStream.ReadTypeRefRow(typeRefRid);
if (typeRefRow == null)
if (!md.TablesStream.TryReadTypeRefRow(typeRefRid, out var typeRefRow))
return false;
if (!CodedToken.ResolutionScope.Decode(typeRefRow.ResolutionScope, out MDToken scope) || scope.Table == Table.TypeRef)
return false;
@ -173,8 +171,7 @@ namespace MakeEverythingPublic {
}
bool IsIVT_TypeDef(uint typeDefRid) {
var typeDefRow = md.TablesStream.ReadTypeDefRow(typeDefRid);
if (typeDefRow == null)
if (!md.TablesStream.TryReadTypeDefRow(typeDefRid, out var typeDefRow))
return false;
if ((typeDefRow.Flags & (uint)TypeAttributes.VisibilityMask) >= (uint)TypeAttributes.NestedPublic)
return false;

View File

@ -103,7 +103,7 @@ namespace MakeEverythingPublic {
var data = File.ReadAllBytes(filename);
try {
using (var peImage = new PEImage(data, filename, ImageLayout.File, verify: true)) {
using (var md = MetaDataCreator.CreateMetaData(peImage, verify: true)) {
using (var md = MetadataCreator.CreateMetadata(peImage, verify: true)) {
var result = new IVTPatcher(data, md, ivtBlob).Patch();
if (result != IVTPatcherResult.OK) {
string errMsg;

View File

@ -60,7 +60,7 @@ namespace dnSpy.AsmEditor.Assembly {
var peImage = fileNode.Document.PEImage;
if (peImage == null)
peImage = (fileNode.Document.ModuleDef as ModuleDefMD)?.MetaData?.PEImage;
peImage = (fileNode.Document.ModuleDef as ModuleDefMD)?.Metadata?.PEImage;
return peImage != null && peImage.IsMemoryMappedIO ? fileNode.Document : null;
}

View File

@ -57,7 +57,7 @@ namespace dnSpy.AsmEditor.Compiler.MDEditor {
var heapInfos = new(long offsetAndSizePosition, long dataPosition, long dataEndPosition)[heapWriters.Count];
// Write the metadata header
var mdHeader = mdWriter.MetadataEditor.RealMetadata.MetaDataHeader;
var mdHeader = mdWriter.MetadataEditor.RealMetadata.MetadataHeader;
stream.Write(0x424A5342);// BSJB
stream.Write(mdHeader.MajorVersion);
stream.Write(mdHeader.MinorVersion);

View File

@ -25,10 +25,10 @@ using dnlib.DotNet.MD;
namespace dnSpy.AsmEditor.Compiler.MDEditor {
sealed class MetadataEditor {
readonly RawModuleBytes moduleData;
readonly IMetaData metadata;
readonly Metadata metadata;
readonly List<MDHeap> heaps;
public IMetaData RealMetadata => metadata;
public Metadata RealMetadata => metadata;
public RawModuleBytes ModuleData => moduleData;
public BlobMDHeap BlobHeap { get; }
@ -37,7 +37,7 @@ namespace dnSpy.AsmEditor.Compiler.MDEditor {
public USMDHeap USHeap { get; }
public TablesMDHeap TablesHeap { get; }
public MetadataEditor(RawModuleBytes moduleData, IMetaData metadata) {
public MetadataEditor(RawModuleBytes moduleData, Metadata metadata) {
this.moduleData = moduleData ?? throw new ArgumentNullException(nameof(moduleData));
this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
@ -83,16 +83,14 @@ namespace dnSpy.AsmEditor.Compiler.MDEditor {
public uint CreateAssemblyRef(IAssembly assembly) {
var rid = TablesHeap.AssemblyRefTable.Create();
var row = TablesHeap.AssemblyRefTable.Get(rid);
row.MajorVersion = (ushort)assembly.Version.Major;
row.MinorVersion = (ushort)assembly.Version.Minor;
row.BuildNumber = (ushort)assembly.Version.Build;
row.RevisionNumber = (ushort)assembly.Version.Revision;
row.Flags = (uint)assembly.Attributes;
row.PublicKeyOrToken = BlobHeap.Create(GetPublicKeyOrTokenBytes(assembly.PublicKeyOrToken));
row.Name = StringsHeap.Create(assembly.Name);
row.Locale = StringsHeap.Create(assembly.Culture);
row.HashValue = BlobHeap.Create((assembly as AssemblyRef)?.Hash);
var row = new RawAssemblyRefRow((ushort)assembly.Version.Major, (ushort)assembly.Version.Minor,
(ushort)assembly.Version.Build, (ushort)assembly.Version.Revision,
(uint)assembly.Attributes,
BlobHeap.Create(GetPublicKeyOrTokenBytes(assembly.PublicKeyOrToken)),
StringsHeap.Create(assembly.Name),
StringsHeap.Create(assembly.Culture),
BlobHeap.Create((assembly as AssemblyRef)?.Hash));
TablesHeap.AssemblyRefTable.Set(rid, ref row);
return rid;
}

View File

@ -0,0 +1,194 @@
/*
Copyright (C) 2014-2018 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using dnlib.DotNet.MD;
namespace dnSpy.AsmEditor.Compiler.MDEditor {
static class RawRowColumnReader {
public delegate uint ReadColumnDelegate<TRow>(ref TRow row, int index) where TRow : struct;
public static Delegate GetDelegate(Table table) {
switch (table) {
case Table.Module: return ReadModuleColumn;
case Table.TypeRef: return ReadTypeRefColumn;
case Table.TypeDef: return ReadTypeDefColumn;
case Table.FieldPtr: return ReadFieldPtrColumn;
case Table.Field: return ReadFieldColumn;
case Table.MethodPtr: return ReadMethodPtrColumn;
case Table.Method: return ReadMethodColumn;
case Table.ParamPtr: return ReadParamPtrColumn;
case Table.Param: return ReadParamColumn;
case Table.InterfaceImpl: return ReadInterfaceImplColumn;
case Table.MemberRef: return ReadMemberRefColumn;
case Table.Constant: return ReadConstantColumn;
case Table.CustomAttribute: return ReadCustomAttributeColumn;
case Table.FieldMarshal: return ReadFieldMarshalColumn;
case Table.DeclSecurity: return ReadDeclSecurityColumn;
case Table.ClassLayout: return ReadClassLayoutColumn;
case Table.FieldLayout: return ReadFieldLayoutColumn;
case Table.StandAloneSig: return ReadStandAloneSigColumn;
case Table.EventMap: return ReadEventMapColumn;
case Table.EventPtr: return ReadEventPtrColumn;
case Table.Event: return ReadEventColumn;
case Table.PropertyMap: return ReadPropertyMapColumn;
case Table.PropertyPtr: return ReadPropertyPtrColumn;
case Table.Property: return ReadPropertyColumn;
case Table.MethodSemantics: return ReadMethodSemanticsColumn;
case Table.MethodImpl: return ReadMethodImplColumn;
case Table.ModuleRef: return ReadModuleRefColumn;
case Table.TypeSpec: return ReadTypeSpecColumn;
case Table.ImplMap: return ReadImplMapColumn;
case Table.FieldRVA: return ReadFieldRVAColumn;
case Table.ENCLog: return ReadENCLogColumn;
case Table.ENCMap: return ReadENCMapColumn;
case Table.Assembly: return ReadAssemblyColumn;
case Table.AssemblyProcessor: return ReadAssemblyProcessorColumn;
case Table.AssemblyOS: return ReadAssemblyOSColumn;
case Table.AssemblyRef: return ReadAssemblyRefColumn;
case Table.AssemblyRefProcessor: return ReadAssemblyRefProcessorColumn;
case Table.AssemblyRefOS: return ReadAssemblyRefOSColumn;
case Table.File: return ReadFileColumn;
case Table.ExportedType: return ReadExportedTypeColumn;
case Table.ManifestResource: return ReadManifestResourceColumn;
case Table.NestedClass: return ReadNestedClassColumn;
case Table.GenericParam: return ReadGenericParamColumn;
case Table.MethodSpec: return ReadMethodSpecColumn;
case Table.GenericParamConstraint: return ReadGenericParamConstraintColumn;
case Table.Document: return ReadDocumentColumn;
case Table.MethodDebugInformation: return ReadMethodDebugInformationColumn;
case Table.LocalScope: return ReadLocalScopeColumn;
case Table.LocalVariable: return ReadLocalVariableColumn;
case Table.LocalConstant: return ReadLocalConstantColumn;
case Table.ImportScope: return ReadImportScopeColumn;
case Table.StateMachineMethod: return ReadStateMachineMethodColumn;
case Table.CustomDebugInformation: return ReadCustomDebugInformationColumn;
default: throw new ArgumentOutOfRangeException(nameof(table));
}
}
public static readonly ReadColumnDelegate<RawModuleRow> ReadModuleColumn = ReadModuleColumnMethod;
public static readonly ReadColumnDelegate<RawTypeRefRow> ReadTypeRefColumn = ReadTypeRefColumnMethod;
public static readonly ReadColumnDelegate<RawTypeDefRow> ReadTypeDefColumn = ReadTypeDefColumnMethod;
public static readonly ReadColumnDelegate<RawFieldPtrRow> ReadFieldPtrColumn = ReadFieldPtrColumnMethod;
public static readonly ReadColumnDelegate<RawFieldRow> ReadFieldColumn = ReadFieldColumnMethod;
public static readonly ReadColumnDelegate<RawMethodPtrRow> ReadMethodPtrColumn = ReadMethodPtrColumnMethod;
public static readonly ReadColumnDelegate<RawMethodRow> ReadMethodColumn = ReadMethodColumnMethod;
public static readonly ReadColumnDelegate<RawParamPtrRow> ReadParamPtrColumn = ReadParamPtrColumnMethod;
public static readonly ReadColumnDelegate<RawParamRow> ReadParamColumn = ReadParamColumnMethod;
public static readonly ReadColumnDelegate<RawInterfaceImplRow> ReadInterfaceImplColumn = ReadInterfaceImplColumnMethod;
public static readonly ReadColumnDelegate<RawMemberRefRow> ReadMemberRefColumn = ReadMemberRefColumnMethod;
public static readonly ReadColumnDelegate<RawConstantRow> ReadConstantColumn = ReadConstantColumnMethod;
public static readonly ReadColumnDelegate<RawCustomAttributeRow> ReadCustomAttributeColumn = ReadCustomAttributeColumnMethod;
public static readonly ReadColumnDelegate<RawFieldMarshalRow> ReadFieldMarshalColumn = ReadFieldMarshalColumnMethod;
public static readonly ReadColumnDelegate<RawDeclSecurityRow> ReadDeclSecurityColumn = ReadDeclSecurityColumnMethod;
public static readonly ReadColumnDelegate<RawClassLayoutRow> ReadClassLayoutColumn = ReadClassLayoutColumnMethod;
public static readonly ReadColumnDelegate<RawFieldLayoutRow> ReadFieldLayoutColumn = ReadFieldLayoutColumnMethod;
public static readonly ReadColumnDelegate<RawStandAloneSigRow> ReadStandAloneSigColumn = ReadStandAloneSigColumnMethod;
public static readonly ReadColumnDelegate<RawEventMapRow> ReadEventMapColumn = ReadEventMapColumnMethod;
public static readonly ReadColumnDelegate<RawEventPtrRow> ReadEventPtrColumn = ReadEventPtrColumnMethod;
public static readonly ReadColumnDelegate<RawEventRow> ReadEventColumn = ReadEventColumnMethod;
public static readonly ReadColumnDelegate<RawPropertyMapRow> ReadPropertyMapColumn = ReadPropertyMapColumnMethod;
public static readonly ReadColumnDelegate<RawPropertyPtrRow> ReadPropertyPtrColumn = ReadPropertyPtrColumnMethod;
public static readonly ReadColumnDelegate<RawPropertyRow> ReadPropertyColumn = ReadPropertyColumnMethod;
public static readonly ReadColumnDelegate<RawMethodSemanticsRow> ReadMethodSemanticsColumn = ReadMethodSemanticsColumnMethod;
public static readonly ReadColumnDelegate<RawMethodImplRow> ReadMethodImplColumn = ReadMethodImplColumnMethod;
public static readonly ReadColumnDelegate<RawModuleRefRow> ReadModuleRefColumn = ReadModuleRefColumnMethod;
public static readonly ReadColumnDelegate<RawTypeSpecRow> ReadTypeSpecColumn = ReadTypeSpecColumnMethod;
public static readonly ReadColumnDelegate<RawImplMapRow> ReadImplMapColumn = ReadImplMapColumnMethod;
public static readonly ReadColumnDelegate<RawFieldRVARow> ReadFieldRVAColumn = ReadFieldRVAColumnMethod;
public static readonly ReadColumnDelegate<RawENCLogRow> ReadENCLogColumn = ReadENCLogColumnMethod;
public static readonly ReadColumnDelegate<RawENCMapRow> ReadENCMapColumn = ReadENCMapColumnMethod;
public static readonly ReadColumnDelegate<RawAssemblyRow> ReadAssemblyColumn = ReadAssemblyColumnMethod;
public static readonly ReadColumnDelegate<RawAssemblyProcessorRow> ReadAssemblyProcessorColumn = ReadAssemblyProcessorColumnMethod;
public static readonly ReadColumnDelegate<RawAssemblyOSRow> ReadAssemblyOSColumn = ReadAssemblyOSColumnMethod;
public static readonly ReadColumnDelegate<RawAssemblyRefRow> ReadAssemblyRefColumn = ReadAssemblyRefColumnMethod;
public static readonly ReadColumnDelegate<RawAssemblyRefProcessorRow> ReadAssemblyRefProcessorColumn = ReadAssemblyRefProcessorColumnMethod;
public static readonly ReadColumnDelegate<RawAssemblyRefOSRow> ReadAssemblyRefOSColumn = ReadAssemblyRefOSColumnMethod;
public static readonly ReadColumnDelegate<RawFileRow> ReadFileColumn = ReadFileColumnMethod;
public static readonly ReadColumnDelegate<RawExportedTypeRow> ReadExportedTypeColumn = ReadExportedTypeColumnMethod;
public static readonly ReadColumnDelegate<RawManifestResourceRow> ReadManifestResourceColumn = ReadManifestResourceColumnMethod;
public static readonly ReadColumnDelegate<RawNestedClassRow> ReadNestedClassColumn = ReadNestedClassColumnMethod;
public static readonly ReadColumnDelegate<RawGenericParamRow> ReadGenericParamColumn = ReadGenericParamColumnMethod;
public static readonly ReadColumnDelegate<RawMethodSpecRow> ReadMethodSpecColumn = ReadMethodSpecColumnMethod;
public static readonly ReadColumnDelegate<RawGenericParamConstraintRow> ReadGenericParamConstraintColumn = ReadGenericParamConstraintColumnMethod;
public static readonly ReadColumnDelegate<RawDocumentRow> ReadDocumentColumn = ReadDocumentColumnMethod;
public static readonly ReadColumnDelegate<RawMethodDebugInformationRow> ReadMethodDebugInformationColumn = ReadMethodDebugInformationColumnMethod;
public static readonly ReadColumnDelegate<RawLocalScopeRow> ReadLocalScopeColumn = ReadLocalScopeColumnMethod;
public static readonly ReadColumnDelegate<RawLocalVariableRow> ReadLocalVariableColumn = ReadLocalVariableColumnMethod;
public static readonly ReadColumnDelegate<RawLocalConstantRow> ReadLocalConstantColumn = ReadLocalConstantColumnMethod;
public static readonly ReadColumnDelegate<RawImportScopeRow> ReadImportScopeColumn = ReadImportScopeColumnMethod;
public static readonly ReadColumnDelegate<RawStateMachineMethodRow> ReadStateMachineMethodColumn = ReadStateMachineMethodColumnMethod;
public static readonly ReadColumnDelegate<RawCustomDebugInformationRow> ReadCustomDebugInformationColumn = ReadCustomDebugInformationColumnMethod;
static uint ReadModuleColumnMethod(ref RawModuleRow row, int index) => row[index];
static uint ReadTypeRefColumnMethod(ref RawTypeRefRow row, int index) => row[index];
static uint ReadTypeDefColumnMethod(ref RawTypeDefRow row, int index) => row[index];
static uint ReadFieldPtrColumnMethod(ref RawFieldPtrRow row, int index) => row[index];
static uint ReadFieldColumnMethod(ref RawFieldRow row, int index) => row[index];
static uint ReadMethodPtrColumnMethod(ref RawMethodPtrRow row, int index) => row[index];
static uint ReadMethodColumnMethod(ref RawMethodRow row, int index) => row[index];
static uint ReadParamPtrColumnMethod(ref RawParamPtrRow row, int index) => row[index];
static uint ReadParamColumnMethod(ref RawParamRow row, int index) => row[index];
static uint ReadInterfaceImplColumnMethod(ref RawInterfaceImplRow row, int index) => row[index];
static uint ReadMemberRefColumnMethod(ref RawMemberRefRow row, int index) => row[index];
static uint ReadConstantColumnMethod(ref RawConstantRow row, int index) => row[index];
static uint ReadCustomAttributeColumnMethod(ref RawCustomAttributeRow row, int index) => row[index];
static uint ReadFieldMarshalColumnMethod(ref RawFieldMarshalRow row, int index) => row[index];
static uint ReadDeclSecurityColumnMethod(ref RawDeclSecurityRow row, int index) => row[index];
static uint ReadClassLayoutColumnMethod(ref RawClassLayoutRow row, int index) => row[index];
static uint ReadFieldLayoutColumnMethod(ref RawFieldLayoutRow row, int index) => row[index];
static uint ReadStandAloneSigColumnMethod(ref RawStandAloneSigRow row, int index) => row[index];
static uint ReadEventMapColumnMethod(ref RawEventMapRow row, int index) => row[index];
static uint ReadEventPtrColumnMethod(ref RawEventPtrRow row, int index) => row[index];
static uint ReadEventColumnMethod(ref RawEventRow row, int index) => row[index];
static uint ReadPropertyMapColumnMethod(ref RawPropertyMapRow row, int index) => row[index];
static uint ReadPropertyPtrColumnMethod(ref RawPropertyPtrRow row, int index) => row[index];
static uint ReadPropertyColumnMethod(ref RawPropertyRow row, int index) => row[index];
static uint ReadMethodSemanticsColumnMethod(ref RawMethodSemanticsRow row, int index) => row[index];
static uint ReadMethodImplColumnMethod(ref RawMethodImplRow row, int index) => row[index];
static uint ReadModuleRefColumnMethod(ref RawModuleRefRow row, int index) => row[index];
static uint ReadTypeSpecColumnMethod(ref RawTypeSpecRow row, int index) => row[index];
static uint ReadImplMapColumnMethod(ref RawImplMapRow row, int index) => row[index];
static uint ReadFieldRVAColumnMethod(ref RawFieldRVARow row, int index) => row[index];
static uint ReadENCLogColumnMethod(ref RawENCLogRow row, int index) => row[index];
static uint ReadENCMapColumnMethod(ref RawENCMapRow row, int index) => row[index];
static uint ReadAssemblyColumnMethod(ref RawAssemblyRow row, int index) => row[index];
static uint ReadAssemblyProcessorColumnMethod(ref RawAssemblyProcessorRow row, int index) => row[index];
static uint ReadAssemblyOSColumnMethod(ref RawAssemblyOSRow row, int index) => row[index];
static uint ReadAssemblyRefColumnMethod(ref RawAssemblyRefRow row, int index) => row[index];
static uint ReadAssemblyRefProcessorColumnMethod(ref RawAssemblyRefProcessorRow row, int index) => row[index];
static uint ReadAssemblyRefOSColumnMethod(ref RawAssemblyRefOSRow row, int index) => row[index];
static uint ReadFileColumnMethod(ref RawFileRow row, int index) => row[index];
static uint ReadExportedTypeColumnMethod(ref RawExportedTypeRow row, int index) => row[index];
static uint ReadManifestResourceColumnMethod(ref RawManifestResourceRow row, int index) => row[index];
static uint ReadNestedClassColumnMethod(ref RawNestedClassRow row, int index) => row[index];
static uint ReadGenericParamColumnMethod(ref RawGenericParamRow row, int index) => row[index];
static uint ReadMethodSpecColumnMethod(ref RawMethodSpecRow row, int index) => row[index];
static uint ReadGenericParamConstraintColumnMethod(ref RawGenericParamConstraintRow row, int index) => row[index];
static uint ReadDocumentColumnMethod(ref RawDocumentRow row, int index) => row[index];
static uint ReadMethodDebugInformationColumnMethod(ref RawMethodDebugInformationRow row, int index) => row[index];
static uint ReadLocalScopeColumnMethod(ref RawLocalScopeRow row, int index) => row[index];
static uint ReadLocalVariableColumnMethod(ref RawLocalVariableRow row, int index) => row[index];
static uint ReadLocalConstantColumnMethod(ref RawLocalConstantRow row, int index) => row[index];
static uint ReadImportScopeColumnMethod(ref RawImportScopeRow row, int index) => row[index];
static uint ReadStateMachineMethodColumnMethod(ref RawStateMachineMethodRow row, int index) => row[index];
static uint ReadCustomDebugInformationColumnMethod(ref RawCustomDebugInformationRow row, int index) => row[index];
}
}

View File

@ -51,13 +51,13 @@ namespace dnSpy.AsmEditor.Compiler.MDEditor {
}
public override void WriteRow(uint rowIndex, IList<ColumnInfo> newColumns, byte[] destination, int destinationIndex) =>
WriteRow(sortedRows[rowIndex], newColumns, destination, destinationIndex);
WriteRow(ref sortedRows[rowIndex], RawRowColumnReader.ReadCustomAttributeColumn, newColumns, destination, destinationIndex);
}
protected void WriteRow<TRow>(TRow row, IList<ColumnInfo> newColumns, byte[] destination, int destinationIndex) where TRow : IRawRow {
protected void WriteRow<TRow>(ref TRow row, RawRowColumnReader.ReadColumnDelegate<TRow> readColumn, IList<ColumnInfo> newColumns, byte[] destination, int destinationIndex) where TRow : struct {
var oldColumns = info.MDTable.Columns;
for (int i = 0; i < newColumns.Count; i++) {
uint value = row.Read(i);
uint value = readColumn(ref row, i);
switch (newColumns[i].Size) {
case 1:
Debug.Assert(newColumns[i].Size == oldColumns[i].Size);

View File

@ -39,9 +39,10 @@ namespace dnSpy.AsmEditor.Compiler.MDEditor {
public abstract void WriteRow(uint rowIndex, IList<ColumnInfo> newColumns, byte[] destination, int destinationIndex);
}
public unsafe sealed class TableInfo<TRow> : TableInfo where TRow : class, IRawRow, new() {
public unsafe sealed class TableInfo<TRow> : TableInfo where TRow : struct {
public override MDTable MDTable { get; }
readonly RawRowColumnReader.ReadColumnDelegate<TRow> readColumn;
readonly RawModuleBytes moduleData;
readonly byte* peFile;
readonly Func<uint, TRow> readRow;
@ -51,6 +52,7 @@ namespace dnSpy.AsmEditor.Compiler.MDEditor {
uint firstModifiedRid;
public TableInfo(RawModuleBytes moduleData, MDTable mdTable, Func<uint, TRow> readRow) {
readColumn = (RawRowColumnReader.ReadColumnDelegate<TRow>)RawRowColumnReader.GetDelegate(mdTable.Table);
this.moduleData = moduleData;
peFile = (byte*)moduleData.Pointer;
MDTable = mdTable;
@ -63,7 +65,7 @@ namespace dnSpy.AsmEditor.Compiler.MDEditor {
public uint Create() {
uint rid = nextRid++;
rowsDict.Add(rid, new TRow());
rowsDict.Add(rid, default);
Debug.Assert(firstModifiedRid <= rid);
return rid;
}
@ -75,7 +77,7 @@ namespace dnSpy.AsmEditor.Compiler.MDEditor {
return readRow(rid);
}
public void Set(uint rid, TRow row) {
public void Set(uint rid, ref TRow row) {
Debug.Assert(rid != 0);
rowsDict[rid] = row;
firstModifiedRid = Math.Min(firstModifiedRid, rid);
@ -91,7 +93,7 @@ namespace dnSpy.AsmEditor.Compiler.MDEditor {
var rid = rowIndex + 1;
if (rid >= firstModifiedRid && rowsDict.TryGetValue(rid, out var row)) {
for (int i = 0; i < newColumns.Count; i++) {
uint value = row.Read(i);
uint value = readColumn(ref row, i);
switch (newColumns[i].Size) {
case 1:
Debug.Assert(newColumns[i].Size == oldColumns[i].Size);
@ -229,59 +231,59 @@ namespace dnSpy.AsmEditor.Compiler.MDEditor {
this.tablesStream = tablesStream ?? throw new ArgumentNullException(nameof(tablesStream));
allTableInfos = new TableInfo[64];
allTableInfos[(int)Table.Module] = ModuleTable = new TableInfo<RawModuleRow>(mdEditor.ModuleData, tablesStream.ModuleTable, rid => this.tablesStream.ReadModuleRow(rid));
allTableInfos[(int)Table.TypeRef] = TypeRefTable = new TableInfo<RawTypeRefRow>(mdEditor.ModuleData, tablesStream.TypeRefTable, rid => this.tablesStream.ReadTypeRefRow(rid));
allTableInfos[(int)Table.TypeDef] = TypeDefTable = new TableInfo<RawTypeDefRow>(mdEditor.ModuleData, tablesStream.TypeDefTable, rid => this.tablesStream.ReadTypeDefRow(rid));
allTableInfos[(int)Table.FieldPtr] = FieldPtrTable = new TableInfo<RawFieldPtrRow>(mdEditor.ModuleData, tablesStream.FieldPtrTable, rid => this.tablesStream.ReadFieldPtrRow(rid));
allTableInfos[(int)Table.Field] = FieldTable = new TableInfo<RawFieldRow>(mdEditor.ModuleData, tablesStream.FieldTable, rid => this.tablesStream.ReadFieldRow(rid));
allTableInfos[(int)Table.MethodPtr] = MethodPtrTable = new TableInfo<RawMethodPtrRow>(mdEditor.ModuleData, tablesStream.MethodPtrTable, rid => this.tablesStream.ReadMethodPtrRow(rid));
allTableInfos[(int)Table.Method] = MethodTable = new TableInfo<RawMethodRow>(mdEditor.ModuleData, tablesStream.MethodTable, rid => this.tablesStream.ReadMethodRow(rid));
allTableInfos[(int)Table.ParamPtr] = ParamPtrTable = new TableInfo<RawParamPtrRow>(mdEditor.ModuleData, tablesStream.ParamPtrTable, rid => this.tablesStream.ReadParamPtrRow(rid));
allTableInfos[(int)Table.Param] = ParamTable = new TableInfo<RawParamRow>(mdEditor.ModuleData, tablesStream.ParamTable, rid => this.tablesStream.ReadParamRow(rid));
allTableInfos[(int)Table.InterfaceImpl] = InterfaceImplTable = new TableInfo<RawInterfaceImplRow>(mdEditor.ModuleData, tablesStream.InterfaceImplTable, rid => this.tablesStream.ReadInterfaceImplRow(rid));
allTableInfos[(int)Table.MemberRef] = MemberRefTable = new TableInfo<RawMemberRefRow>(mdEditor.ModuleData, tablesStream.MemberRefTable, rid => this.tablesStream.ReadMemberRefRow(rid));
allTableInfos[(int)Table.Constant] = ConstantTable = new TableInfo<RawConstantRow>(mdEditor.ModuleData, tablesStream.ConstantTable, rid => this.tablesStream.ReadConstantRow(rid));
allTableInfos[(int)Table.CustomAttribute] = CustomAttributeTable = new TableInfo<RawCustomAttributeRow>(mdEditor.ModuleData, tablesStream.CustomAttributeTable, rid => this.tablesStream.ReadCustomAttributeRow(rid));
allTableInfos[(int)Table.FieldMarshal] = FieldMarshalTable = new TableInfo<RawFieldMarshalRow>(mdEditor.ModuleData, tablesStream.FieldMarshalTable, rid => this.tablesStream.ReadFieldMarshalRow(rid));
allTableInfos[(int)Table.DeclSecurity] = DeclSecurityTable = new TableInfo<RawDeclSecurityRow>(mdEditor.ModuleData, tablesStream.DeclSecurityTable, rid => this.tablesStream.ReadDeclSecurityRow(rid));
allTableInfos[(int)Table.ClassLayout] = ClassLayoutTable = new TableInfo<RawClassLayoutRow>(mdEditor.ModuleData, tablesStream.ClassLayoutTable, rid => this.tablesStream.ReadClassLayoutRow(rid));
allTableInfos[(int)Table.FieldLayout] = FieldLayoutTable = new TableInfo<RawFieldLayoutRow>(mdEditor.ModuleData, tablesStream.FieldLayoutTable, rid => this.tablesStream.ReadFieldLayoutRow(rid));
allTableInfos[(int)Table.StandAloneSig] = StandAloneSigTable = new TableInfo<RawStandAloneSigRow>(mdEditor.ModuleData, tablesStream.StandAloneSigTable, rid => this.tablesStream.ReadStandAloneSigRow(rid));
allTableInfos[(int)Table.EventMap] = EventMapTable = new TableInfo<RawEventMapRow>(mdEditor.ModuleData, tablesStream.EventMapTable, rid => this.tablesStream.ReadEventMapRow(rid));
allTableInfos[(int)Table.EventPtr] = EventPtrTable = new TableInfo<RawEventPtrRow>(mdEditor.ModuleData, tablesStream.EventPtrTable, rid => this.tablesStream.ReadEventPtrRow(rid));
allTableInfos[(int)Table.Event] = EventTable = new TableInfo<RawEventRow>(mdEditor.ModuleData, tablesStream.EventTable, rid => this.tablesStream.ReadEventRow(rid));
allTableInfos[(int)Table.PropertyMap] = PropertyMapTable = new TableInfo<RawPropertyMapRow>(mdEditor.ModuleData, tablesStream.PropertyMapTable, rid => this.tablesStream.ReadPropertyMapRow(rid));
allTableInfos[(int)Table.PropertyPtr] = PropertyPtrTable = new TableInfo<RawPropertyPtrRow>(mdEditor.ModuleData, tablesStream.PropertyPtrTable, rid => this.tablesStream.ReadPropertyPtrRow(rid));
allTableInfos[(int)Table.Property] = PropertyTable = new TableInfo<RawPropertyRow>(mdEditor.ModuleData, tablesStream.PropertyTable, rid => this.tablesStream.ReadPropertyRow(rid));
allTableInfos[(int)Table.MethodSemantics] = MethodSemanticsTable = new TableInfo<RawMethodSemanticsRow>(mdEditor.ModuleData, tablesStream.MethodSemanticsTable, rid => this.tablesStream.ReadMethodSemanticsRow(rid));
allTableInfos[(int)Table.MethodImpl] = MethodImplTable = new TableInfo<RawMethodImplRow>(mdEditor.ModuleData, tablesStream.MethodImplTable, rid => this.tablesStream.ReadMethodImplRow(rid));
allTableInfos[(int)Table.ModuleRef] = ModuleRefTable = new TableInfo<RawModuleRefRow>(mdEditor.ModuleData, tablesStream.ModuleRefTable, rid => this.tablesStream.ReadModuleRefRow(rid));
allTableInfos[(int)Table.TypeSpec] = TypeSpecTable = new TableInfo<RawTypeSpecRow>(mdEditor.ModuleData, tablesStream.TypeSpecTable, rid => this.tablesStream.ReadTypeSpecRow(rid));
allTableInfos[(int)Table.ImplMap] = ImplMapTable = new TableInfo<RawImplMapRow>(mdEditor.ModuleData, tablesStream.ImplMapTable, rid => this.tablesStream.ReadImplMapRow(rid));
allTableInfos[(int)Table.FieldRVA] = FieldRVATable = new TableInfo<RawFieldRVARow>(mdEditor.ModuleData, tablesStream.FieldRVATable, rid => this.tablesStream.ReadFieldRVARow(rid));
allTableInfos[(int)Table.ENCLog] = ENCLogTable = new TableInfo<RawENCLogRow>(mdEditor.ModuleData, tablesStream.ENCLogTable, rid => this.tablesStream.ReadENCLogRow(rid));
allTableInfos[(int)Table.ENCMap] = ENCMapTable = new TableInfo<RawENCMapRow>(mdEditor.ModuleData, tablesStream.ENCMapTable, rid => this.tablesStream.ReadENCMapRow(rid));
allTableInfos[(int)Table.Assembly] = AssemblyTable = new TableInfo<RawAssemblyRow>(mdEditor.ModuleData, tablesStream.AssemblyTable, rid => this.tablesStream.ReadAssemblyRow(rid));
allTableInfos[(int)Table.AssemblyProcessor] = AssemblyProcessorTable = new TableInfo<RawAssemblyProcessorRow>(mdEditor.ModuleData, tablesStream.AssemblyProcessorTable, rid => this.tablesStream.ReadAssemblyProcessorRow(rid));
allTableInfos[(int)Table.AssemblyOS] = AssemblyOSTable = new TableInfo<RawAssemblyOSRow>(mdEditor.ModuleData, tablesStream.AssemblyOSTable, rid => this.tablesStream.ReadAssemblyOSRow(rid));
allTableInfos[(int)Table.AssemblyRef] = AssemblyRefTable = new TableInfo<RawAssemblyRefRow>(mdEditor.ModuleData, tablesStream.AssemblyRefTable, rid => this.tablesStream.ReadAssemblyRefRow(rid));
allTableInfos[(int)Table.AssemblyRefProcessor] = AssemblyRefProcessorTable = new TableInfo<RawAssemblyRefProcessorRow>(mdEditor.ModuleData, tablesStream.AssemblyRefProcessorTable, rid => this.tablesStream.ReadAssemblyRefProcessorRow(rid));
allTableInfos[(int)Table.AssemblyRefOS] = AssemblyRefOSTable = new TableInfo<RawAssemblyRefOSRow>(mdEditor.ModuleData, tablesStream.AssemblyRefOSTable, rid => this.tablesStream.ReadAssemblyRefOSRow(rid));
allTableInfos[(int)Table.File] = FileTable = new TableInfo<RawFileRow>(mdEditor.ModuleData, tablesStream.FileTable, rid => this.tablesStream.ReadFileRow(rid));
allTableInfos[(int)Table.ExportedType] = ExportedTypeTable = new TableInfo<RawExportedTypeRow>(mdEditor.ModuleData, tablesStream.ExportedTypeTable, rid => this.tablesStream.ReadExportedTypeRow(rid));
allTableInfos[(int)Table.ManifestResource] = ManifestResourceTable = new TableInfo<RawManifestResourceRow>(mdEditor.ModuleData, tablesStream.ManifestResourceTable, rid => this.tablesStream.ReadManifestResourceRow(rid));
allTableInfos[(int)Table.NestedClass] = NestedClassTable = new TableInfo<RawNestedClassRow>(mdEditor.ModuleData, tablesStream.NestedClassTable, rid => this.tablesStream.ReadNestedClassRow(rid));
allTableInfos[(int)Table.GenericParam] = GenericParamTable = new TableInfo<RawGenericParamRow>(mdEditor.ModuleData, tablesStream.GenericParamTable, rid => this.tablesStream.ReadGenericParamRow(rid));
allTableInfos[(int)Table.MethodSpec] = MethodSpecTable = new TableInfo<RawMethodSpecRow>(mdEditor.ModuleData, tablesStream.MethodSpecTable, rid => this.tablesStream.ReadMethodSpecRow(rid));
allTableInfos[(int)Table.GenericParamConstraint] = GenericParamConstraintTable = new TableInfo<RawGenericParamConstraintRow>(mdEditor.ModuleData, tablesStream.GenericParamConstraintTable, rid => this.tablesStream.ReadGenericParamConstraintRow(rid));
allTableInfos[(int)Table.Document] = DocumentTable = new TableInfo<RawDocumentRow>(mdEditor.ModuleData, tablesStream.DocumentTable, rid => this.tablesStream.ReadDocumentRow(rid));
allTableInfos[(int)Table.MethodDebugInformation] = MethodDebugInformationTable = new TableInfo<RawMethodDebugInformationRow>(mdEditor.ModuleData, tablesStream.MethodDebugInformationTable, rid => this.tablesStream.ReadMethodDebugInformationRow(rid));
allTableInfos[(int)Table.LocalScope] = LocalScopeTable = new TableInfo<RawLocalScopeRow>(mdEditor.ModuleData, tablesStream.LocalScopeTable, rid => this.tablesStream.ReadLocalScopeRow(rid));
allTableInfos[(int)Table.LocalVariable] = LocalVariableTable = new TableInfo<RawLocalVariableRow>(mdEditor.ModuleData, tablesStream.LocalVariableTable, rid => this.tablesStream.ReadLocalVariableRow(rid));
allTableInfos[(int)Table.LocalConstant] = LocalConstantTable = new TableInfo<RawLocalConstantRow>(mdEditor.ModuleData, tablesStream.LocalConstantTable, rid => this.tablesStream.ReadLocalConstantRow(rid));
allTableInfos[(int)Table.ImportScope] = ImportScopeTable = new TableInfo<RawImportScopeRow>(mdEditor.ModuleData, tablesStream.ImportScopeTable, rid => this.tablesStream.ReadImportScopeRow(rid));
allTableInfos[(int)Table.StateMachineMethod] = StateMachineMethodTable = new TableInfo<RawStateMachineMethodRow>(mdEditor.ModuleData, tablesStream.StateMachineMethodTable, rid => this.tablesStream.ReadStateMachineMethodRow(rid));
allTableInfos[(int)Table.CustomDebugInformation] = CustomDebugInformationTable = new TableInfo<RawCustomDebugInformationRow>(mdEditor.ModuleData, tablesStream.CustomDebugInformationTable, rid => this.tablesStream.ReadCustomDebugInformationRow(rid));
allTableInfos[(int)Table.Module] = ModuleTable = new TableInfo<RawModuleRow>(mdEditor.ModuleData, tablesStream.ModuleTable, rid => { this.tablesStream.TryReadModuleRow(rid, out var row); return row; });
allTableInfos[(int)Table.TypeRef] = TypeRefTable = new TableInfo<RawTypeRefRow>(mdEditor.ModuleData, tablesStream.TypeRefTable, rid => { this.tablesStream.TryReadTypeRefRow(rid, out var row); return row; });
allTableInfos[(int)Table.TypeDef] = TypeDefTable = new TableInfo<RawTypeDefRow>(mdEditor.ModuleData, tablesStream.TypeDefTable, rid => { this.tablesStream.TryReadTypeDefRow(rid, out var row); return row; });
allTableInfos[(int)Table.FieldPtr] = FieldPtrTable = new TableInfo<RawFieldPtrRow>(mdEditor.ModuleData, tablesStream.FieldPtrTable, rid => { this.tablesStream.TryReadFieldPtrRow(rid, out var row); return row; });
allTableInfos[(int)Table.Field] = FieldTable = new TableInfo<RawFieldRow>(mdEditor.ModuleData, tablesStream.FieldTable, rid => { this.tablesStream.TryReadFieldRow(rid, out var row); return row; });
allTableInfos[(int)Table.MethodPtr] = MethodPtrTable = new TableInfo<RawMethodPtrRow>(mdEditor.ModuleData, tablesStream.MethodPtrTable, rid => { this.tablesStream.TryReadMethodPtrRow(rid, out var row); return row; });
allTableInfos[(int)Table.Method] = MethodTable = new TableInfo<RawMethodRow>(mdEditor.ModuleData, tablesStream.MethodTable, rid => { this.tablesStream.TryReadMethodRow(rid, out var row); return row; });
allTableInfos[(int)Table.ParamPtr] = ParamPtrTable = new TableInfo<RawParamPtrRow>(mdEditor.ModuleData, tablesStream.ParamPtrTable, rid => { this.tablesStream.TryReadParamPtrRow(rid, out var row); return row; });
allTableInfos[(int)Table.Param] = ParamTable = new TableInfo<RawParamRow>(mdEditor.ModuleData, tablesStream.ParamTable, rid => { this.tablesStream.TryReadParamRow(rid, out var row); return row; });
allTableInfos[(int)Table.InterfaceImpl] = InterfaceImplTable = new TableInfo<RawInterfaceImplRow>(mdEditor.ModuleData, tablesStream.InterfaceImplTable, rid => { this.tablesStream.TryReadInterfaceImplRow(rid, out var row); return row; });
allTableInfos[(int)Table.MemberRef] = MemberRefTable = new TableInfo<RawMemberRefRow>(mdEditor.ModuleData, tablesStream.MemberRefTable, rid => { this.tablesStream.TryReadMemberRefRow(rid, out var row); return row; });
allTableInfos[(int)Table.Constant] = ConstantTable = new TableInfo<RawConstantRow>(mdEditor.ModuleData, tablesStream.ConstantTable, rid => { this.tablesStream.TryReadConstantRow(rid, out var row); return row; });
allTableInfos[(int)Table.CustomAttribute] = CustomAttributeTable = new TableInfo<RawCustomAttributeRow>(mdEditor.ModuleData, tablesStream.CustomAttributeTable, rid => { this.tablesStream.TryReadCustomAttributeRow(rid, out var row); return row; });
allTableInfos[(int)Table.FieldMarshal] = FieldMarshalTable = new TableInfo<RawFieldMarshalRow>(mdEditor.ModuleData, tablesStream.FieldMarshalTable, rid => { this.tablesStream.TryReadFieldMarshalRow(rid, out var row); return row; });
allTableInfos[(int)Table.DeclSecurity] = DeclSecurityTable = new TableInfo<RawDeclSecurityRow>(mdEditor.ModuleData, tablesStream.DeclSecurityTable, rid => { this.tablesStream.TryReadDeclSecurityRow(rid, out var row); return row; });
allTableInfos[(int)Table.ClassLayout] = ClassLayoutTable = new TableInfo<RawClassLayoutRow>(mdEditor.ModuleData, tablesStream.ClassLayoutTable, rid => { this.tablesStream.TryReadClassLayoutRow(rid, out var row); return row; });
allTableInfos[(int)Table.FieldLayout] = FieldLayoutTable = new TableInfo<RawFieldLayoutRow>(mdEditor.ModuleData, tablesStream.FieldLayoutTable, rid => { this.tablesStream.TryReadFieldLayoutRow(rid, out var row); return row; });
allTableInfos[(int)Table.StandAloneSig] = StandAloneSigTable = new TableInfo<RawStandAloneSigRow>(mdEditor.ModuleData, tablesStream.StandAloneSigTable, rid => { this.tablesStream.TryReadStandAloneSigRow(rid, out var row); return row; });
allTableInfos[(int)Table.EventMap] = EventMapTable = new TableInfo<RawEventMapRow>(mdEditor.ModuleData, tablesStream.EventMapTable, rid => { this.tablesStream.TryReadEventMapRow(rid, out var row); return row; });
allTableInfos[(int)Table.EventPtr] = EventPtrTable = new TableInfo<RawEventPtrRow>(mdEditor.ModuleData, tablesStream.EventPtrTable, rid => { this.tablesStream.TryReadEventPtrRow(rid, out var row); return row; });
allTableInfos[(int)Table.Event] = EventTable = new TableInfo<RawEventRow>(mdEditor.ModuleData, tablesStream.EventTable, rid => { this.tablesStream.TryReadEventRow(rid, out var row); return row; });
allTableInfos[(int)Table.PropertyMap] = PropertyMapTable = new TableInfo<RawPropertyMapRow>(mdEditor.ModuleData, tablesStream.PropertyMapTable, rid => { this.tablesStream.TryReadPropertyMapRow(rid, out var row); return row; });
allTableInfos[(int)Table.PropertyPtr] = PropertyPtrTable = new TableInfo<RawPropertyPtrRow>(mdEditor.ModuleData, tablesStream.PropertyPtrTable, rid => { this.tablesStream.TryReadPropertyPtrRow(rid, out var row); return row; });
allTableInfos[(int)Table.Property] = PropertyTable = new TableInfo<RawPropertyRow>(mdEditor.ModuleData, tablesStream.PropertyTable, rid => { this.tablesStream.TryReadPropertyRow(rid, out var row); return row; });
allTableInfos[(int)Table.MethodSemantics] = MethodSemanticsTable = new TableInfo<RawMethodSemanticsRow>(mdEditor.ModuleData, tablesStream.MethodSemanticsTable, rid => { this.tablesStream.TryReadMethodSemanticsRow(rid, out var row); return row; });
allTableInfos[(int)Table.MethodImpl] = MethodImplTable = new TableInfo<RawMethodImplRow>(mdEditor.ModuleData, tablesStream.MethodImplTable, rid => { this.tablesStream.TryReadMethodImplRow(rid, out var row); return row; });
allTableInfos[(int)Table.ModuleRef] = ModuleRefTable = new TableInfo<RawModuleRefRow>(mdEditor.ModuleData, tablesStream.ModuleRefTable, rid => { this.tablesStream.TryReadModuleRefRow(rid, out var row); return row; });
allTableInfos[(int)Table.TypeSpec] = TypeSpecTable = new TableInfo<RawTypeSpecRow>(mdEditor.ModuleData, tablesStream.TypeSpecTable, rid => { this.tablesStream.TryReadTypeSpecRow(rid, out var row); return row; });
allTableInfos[(int)Table.ImplMap] = ImplMapTable = new TableInfo<RawImplMapRow>(mdEditor.ModuleData, tablesStream.ImplMapTable, rid => { this.tablesStream.TryReadImplMapRow(rid, out var row); return row; });
allTableInfos[(int)Table.FieldRVA] = FieldRVATable = new TableInfo<RawFieldRVARow>(mdEditor.ModuleData, tablesStream.FieldRVATable, rid => { this.tablesStream.TryReadFieldRVARow(rid, out var row); return row; });
allTableInfos[(int)Table.ENCLog] = ENCLogTable = new TableInfo<RawENCLogRow>(mdEditor.ModuleData, tablesStream.ENCLogTable, rid => { this.tablesStream.TryReadENCLogRow(rid, out var row); return row; });
allTableInfos[(int)Table.ENCMap] = ENCMapTable = new TableInfo<RawENCMapRow>(mdEditor.ModuleData, tablesStream.ENCMapTable, rid => { this.tablesStream.TryReadENCMapRow(rid, out var row); return row; });
allTableInfos[(int)Table.Assembly] = AssemblyTable = new TableInfo<RawAssemblyRow>(mdEditor.ModuleData, tablesStream.AssemblyTable, rid => { this.tablesStream.TryReadAssemblyRow(rid, out var row); return row; });
allTableInfos[(int)Table.AssemblyProcessor] = AssemblyProcessorTable = new TableInfo<RawAssemblyProcessorRow>(mdEditor.ModuleData, tablesStream.AssemblyProcessorTable, rid => { this.tablesStream.TryReadAssemblyProcessorRow(rid, out var row); return row; });
allTableInfos[(int)Table.AssemblyOS] = AssemblyOSTable = new TableInfo<RawAssemblyOSRow>(mdEditor.ModuleData, tablesStream.AssemblyOSTable, rid => { this.tablesStream.TryReadAssemblyOSRow(rid, out var row); return row; });
allTableInfos[(int)Table.AssemblyRef] = AssemblyRefTable = new TableInfo<RawAssemblyRefRow>(mdEditor.ModuleData, tablesStream.AssemblyRefTable, rid => { this.tablesStream.TryReadAssemblyRefRow(rid, out var row); return row; });
allTableInfos[(int)Table.AssemblyRefProcessor] = AssemblyRefProcessorTable = new TableInfo<RawAssemblyRefProcessorRow>(mdEditor.ModuleData, tablesStream.AssemblyRefProcessorTable, rid => { this.tablesStream.TryReadAssemblyRefProcessorRow(rid, out var row); return row; });
allTableInfos[(int)Table.AssemblyRefOS] = AssemblyRefOSTable = new TableInfo<RawAssemblyRefOSRow>(mdEditor.ModuleData, tablesStream.AssemblyRefOSTable, rid => { this.tablesStream.TryReadAssemblyRefOSRow(rid, out var row); return row; });
allTableInfos[(int)Table.File] = FileTable = new TableInfo<RawFileRow>(mdEditor.ModuleData, tablesStream.FileTable, rid => { this.tablesStream.TryReadFileRow(rid, out var row); return row; });
allTableInfos[(int)Table.ExportedType] = ExportedTypeTable = new TableInfo<RawExportedTypeRow>(mdEditor.ModuleData, tablesStream.ExportedTypeTable, rid => { this.tablesStream.TryReadExportedTypeRow(rid, out var row); return row; });
allTableInfos[(int)Table.ManifestResource] = ManifestResourceTable = new TableInfo<RawManifestResourceRow>(mdEditor.ModuleData, tablesStream.ManifestResourceTable, rid => { this.tablesStream.TryReadManifestResourceRow(rid, out var row); return row; });
allTableInfos[(int)Table.NestedClass] = NestedClassTable = new TableInfo<RawNestedClassRow>(mdEditor.ModuleData, tablesStream.NestedClassTable, rid => { this.tablesStream.TryReadNestedClassRow(rid, out var row); return row; });
allTableInfos[(int)Table.GenericParam] = GenericParamTable = new TableInfo<RawGenericParamRow>(mdEditor.ModuleData, tablesStream.GenericParamTable, rid => { this.tablesStream.TryReadGenericParamRow(rid, out var row); return row; });
allTableInfos[(int)Table.MethodSpec] = MethodSpecTable = new TableInfo<RawMethodSpecRow>(mdEditor.ModuleData, tablesStream.MethodSpecTable, rid => { this.tablesStream.TryReadMethodSpecRow(rid, out var row); return row; });
allTableInfos[(int)Table.GenericParamConstraint] = GenericParamConstraintTable = new TableInfo<RawGenericParamConstraintRow>(mdEditor.ModuleData, tablesStream.GenericParamConstraintTable, rid => { this.tablesStream.TryReadGenericParamConstraintRow(rid, out var row); return row; });
allTableInfos[(int)Table.Document] = DocumentTable = new TableInfo<RawDocumentRow>(mdEditor.ModuleData, tablesStream.DocumentTable, rid => { this.tablesStream.TryReadDocumentRow(rid, out var row); return row; });
allTableInfos[(int)Table.MethodDebugInformation] = MethodDebugInformationTable = new TableInfo<RawMethodDebugInformationRow>(mdEditor.ModuleData, tablesStream.MethodDebugInformationTable, rid => { this.tablesStream.TryReadMethodDebugInformationRow(rid, out var row); return row; });
allTableInfos[(int)Table.LocalScope] = LocalScopeTable = new TableInfo<RawLocalScopeRow>(mdEditor.ModuleData, tablesStream.LocalScopeTable, rid => { this.tablesStream.TryReadLocalScopeRow(rid, out var row); return row; });
allTableInfos[(int)Table.LocalVariable] = LocalVariableTable = new TableInfo<RawLocalVariableRow>(mdEditor.ModuleData, tablesStream.LocalVariableTable, rid => { this.tablesStream.TryReadLocalVariableRow(rid, out var row); return row; });
allTableInfos[(int)Table.LocalConstant] = LocalConstantTable = new TableInfo<RawLocalConstantRow>(mdEditor.ModuleData, tablesStream.LocalConstantTable, rid => { this.tablesStream.TryReadLocalConstantRow(rid, out var row); return row; });
allTableInfos[(int)Table.ImportScope] = ImportScopeTable = new TableInfo<RawImportScopeRow>(mdEditor.ModuleData, tablesStream.ImportScopeTable, rid => { this.tablesStream.TryReadImportScopeRow(rid, out var row); return row; });
allTableInfos[(int)Table.StateMachineMethod] = StateMachineMethodTable = new TableInfo<RawStateMachineMethodRow>(mdEditor.ModuleData, tablesStream.StateMachineMethodTable, rid => { this.tablesStream.TryReadStateMachineMethodRow(rid, out var row); return row; });
allTableInfos[(int)Table.CustomDebugInformation] = CustomDebugInformationTable = new TableInfo<RawCustomDebugInformationRow>(mdEditor.ModuleData, tablesStream.CustomDebugInformationTable, rid => { this.tablesStream.TryReadCustomDebugInformationRow(rid, out var row); return row; });
}
public override bool MustRewriteHeap() {

View File

@ -82,32 +82,33 @@ namespace dnSpy.AsmEditor.Compiler {
var dict = new Dictionary<TypeDef, (TypeDef Type, uint TypeRefRid, RawTypeRefRow TypeRefRow)>();
foreach (var type in MDPatcherUtils.GetMetadataTypes(nonNestedTypeDef)) {
var typeRefRid = mdEditor.TablesHeap.TypeRefTable.Create();
var deletedType = (Type: type, TypeRefRid: typeRefRid, TypeRefRow: mdEditor.TablesHeap.TypeRefTable.Get(typeRefRid));
dict.Add(type, deletedType);
remappedTypeTokens.Add(type.MDToken.Raw, new MDToken(Table.TypeRef, typeRefRid).Raw);
// Remove the type by renaming it and making it private/internal
var tdRow = mdEditor.TablesHeap.TypeDefTable.Get(type.Rid);
deletedType.TypeRefRow.Name = tdRow.Name;
deletedType.TypeRefRow.Namespace = tdRow.Namespace;
tdRow.Name = mdEditor.StringsHeap.Create(Guid.NewGuid().ToString());
tdRow.Namespace = mdEditor.StringsHeap.Create(string.Empty);
if ((tdRow.Flags & 7) <= 1)
tdRow.Flags = tdRow.Flags & ~7U; // NotPublic
var flags = tdRow.Flags;
if ((flags & 7) <= 1)
flags = flags & ~7U; // NotPublic
else
tdRow.Flags = (tdRow.Flags & ~7U) | 3; // NestedPrivate
mdEditor.TablesHeap.TypeDefTable.Set(type.Rid, tdRow);
flags = (flags & ~7U) | 3; // NestedPrivate
var deletedType = (Type: type, TypeRefRid: typeRefRid, TypeRefRow: new RawTypeRefRow(0, tdRow.Name, tdRow.Namespace));
tdRow = new RawTypeDefRow(flags, mdEditor.StringsHeap.Create(Guid.NewGuid().ToString()), mdEditor.StringsHeap.Create(string.Empty), tdRow.Extends, tdRow.FieldList, tdRow.MethodList);
mdEditor.TablesHeap.TypeDefTable.Set(type.Rid, ref tdRow);
dict.Add(type, deletedType);
}
remappedTypeTokens.SetReadOnly();
foreach (var kv in dict) {
var deletedType = kv.Value;
uint resolutionScope;
if (deletedType.Type.DeclaringType != null) {
var declType = dict[deletedType.Type.DeclaringType];
deletedType.TypeRefRow.ResolutionScope = CodedToken.ResolutionScope.Encode(new MDToken(Table.TypeRef, declType.TypeRefRid));
resolutionScope = CodedToken.ResolutionScope.Encode(new MDToken(Table.TypeRef, declType.TypeRefRid));
}
else
deletedType.TypeRefRow.ResolutionScope = CodedToken.ResolutionScope.Encode(new MDToken(Table.AssemblyRef, GetOrCreateTempAssemblyRid()));
resolutionScope = CodedToken.ResolutionScope.Encode(new MDToken(Table.AssemblyRef, GetOrCreateTempAssemblyRid()));
deletedType.TypeRefRow = new RawTypeRefRow(resolutionScope, deletedType.TypeRefRow.Name, deletedType.TypeRefRow.Namespace);
mdEditor.TablesHeap.TypeRefTable.Set(deletedType.TypeRefRid, ref deletedType.TypeRefRow);
}
}
@ -153,8 +154,8 @@ namespace dnSpy.AsmEditor.Compiler {
continue;
var typeRefRow = mdEditor.TablesHeap.TypeRefTable.Get(i + 1);
typeRefRow.ResolutionScope = CodedToken.ResolutionScope.Encode(new MDToken(Table.AssemblyRef, GetOrCreateTempAssemblyRid()));
mdEditor.TablesHeap.TypeRefTable.Set(i + 1, typeRefRow);
typeRefRow = new RawTypeRefRow(CodedToken.ResolutionScope.Encode(new MDToken(Table.AssemblyRef, GetOrCreateTempAssemblyRid())), typeRefRow.Name, typeRefRow.Namespace);
mdEditor.TablesHeap.TypeRefTable.Set(i + 1, ref typeRefRow);
}
}
}
@ -165,8 +166,7 @@ namespace dnSpy.AsmEditor.Compiler {
return resolutionScope.Rid == 1;
case Table.ModuleRef:
var moduleRefRow = mdEditor.RealMetadata.TablesStream.ReadModuleRefRow(resolutionScope.Rid);
if (moduleRefRow == null)
if (!mdEditor.RealMetadata.TablesStream.TryReadModuleRefRow(resolutionScope.Rid, out var moduleRefRow))
return false;
var moduleRefName = mdEditor.RealMetadata.StringsStream.ReadNoNull(moduleRefRow.Name);
return StringComparer.OrdinalIgnoreCase.Equals(moduleRefName.String, module.Name.String);
@ -175,7 +175,8 @@ namespace dnSpy.AsmEditor.Compiler {
var asm = module.Assembly;
if (asm == null)
return false;
var assemblyRefRow = mdEditor.RealMetadata.TablesStream.ReadAssemblyRefRow(resolutionScope.Rid);
if (!mdEditor.RealMetadata.TablesStream.TryReadAssemblyRefRow(resolutionScope.Rid, out var assemblyRefRow))
return false;
// The version number isn't checked due to binding redirects
var assemblyRefName = mdEditor.RealMetadata.StringsStream.ReadNoNull(assemblyRefRow.Name);
if (!StringComparer.OrdinalIgnoreCase.Equals(assemblyRefName.String, UTF8String.ToSystemStringOrEmpty(asm.Name)))
@ -268,8 +269,8 @@ namespace dnSpy.AsmEditor.Compiler {
continue;
if (remappedTypeTokens.TryGetValue(token.Raw, out newToken)) {
var row = tablesHeap.TypeDefTable.Get(i + 1);
row.Extends = CodedToken.TypeDefOrRef.Encode(newToken);
tablesHeap.TypeDefTable.Set(i + 1, row);
row = new RawTypeDefRow(row.Flags, row.Name, row.Namespace, CodedToken.TypeDefOrRef.Encode(newToken), row.FieldList, row.MethodList);
tablesHeap.TypeDefTable.Set(i + 1, ref row);
}
}
}
@ -286,8 +287,8 @@ namespace dnSpy.AsmEditor.Compiler {
newSig = PatchCallingConventionSignature(callConvSigDict, sig);
if (newSig != sig) {
var row = tablesHeap.FieldTable.Get(i + 1);
row.Signature = newSig;
tablesHeap.FieldTable.Set(i + 1, row);
row = new RawFieldRow(row.Flags, row.Name, newSig);
tablesHeap.FieldTable.Set(i + 1, ref row);
}
}
}
@ -304,8 +305,8 @@ namespace dnSpy.AsmEditor.Compiler {
newSig = PatchCallingConventionSignature(callConvSigDict, sig);
if (newSig != sig) {
var row = tablesHeap.MethodTable.Get(i + 1);
row.Signature = newSig;
tablesHeap.MethodTable.Set(i + 1, row);
row = new RawMethodRow(row.RVA, row.ImplFlags, row.Flags, row.Name, newSig, row.ParamList);
tablesHeap.MethodTable.Set(i + 1, ref row);
}
}
}
@ -323,8 +324,8 @@ namespace dnSpy.AsmEditor.Compiler {
continue;
if (remappedTypeTokens.TryGetValue(token.Raw, out newToken)) {
var row = tablesHeap.InterfaceImplTable.Get(i + 1);
row.Interface = CodedToken.TypeDefOrRef.Encode(newToken);
tablesHeap.InterfaceImplTable.Set(i + 1, row);
row = new RawInterfaceImplRow(row.Class, CodedToken.TypeDefOrRef.Encode(newToken));
tablesHeap.InterfaceImplTable.Set(i + 1, ref row);
}
}
}
@ -353,8 +354,8 @@ namespace dnSpy.AsmEditor.Compiler {
case Table.TypeSpec:
if (remappedTypeTokens.TryGetValue(token.Raw, out newToken)) {
row = tablesHeap.MemberRefTable.Get(rid);
row.Class = CodedToken.MemberRefParent.Encode(newToken);
tablesHeap.MemberRefTable.Set(rid, row);
row = new RawMemberRefRow(CodedToken.MemberRefParent.Encode(newToken), row.Name, row.Signature);
tablesHeap.MemberRefTable.Set(rid, ref row);
}
break;
@ -362,8 +363,8 @@ namespace dnSpy.AsmEditor.Compiler {
if (nonNestedEditedType.IsGlobalModuleType && CheckResolutionScopeIsSameModule(token, nonNestedEditedType.Module)) {
if (remappedTypeTokens.TryGetValue(nonNestedEditedType.MDToken.Raw, out newToken)) {
row = tablesHeap.MemberRefTable.Get(rid);
row.Class = CodedToken.MemberRefParent.Encode(newToken);
tablesHeap.MemberRefTable.Set(rid, row);
row = new RawMemberRefRow(CodedToken.MemberRefParent.Encode(newToken), row.Name, row.Signature);
tablesHeap.MemberRefTable.Set(rid, ref row);
}
}
break;
@ -380,8 +381,8 @@ namespace dnSpy.AsmEditor.Compiler {
newSig = PatchCallingConventionSignature(callConvSigDict, sig);
if (sig != newSig) {
row = tablesHeap.MemberRefTable.Get(rid);
row.Signature = newSig;
tablesHeap.MemberRefTable.Set(rid, row);
row = new RawMemberRefRow(row.Class, row.Name, newSig);
tablesHeap.MemberRefTable.Set(rid, ref row);
}
}
}
@ -399,8 +400,8 @@ namespace dnSpy.AsmEditor.Compiler {
continue;
if (remappedTypeTokens.TryGetValue(token.Raw, out newToken)) {
var row = tablesHeap.EventTable.Get(i + 1);
row.EventType = CodedToken.TypeDefOrRef.Encode(newToken);
tablesHeap.EventTable.Set(i + 1, row);
row = new RawEventRow(row.EventFlags, row.Name, CodedToken.TypeDefOrRef.Encode(newToken));
tablesHeap.EventTable.Set(i + 1, ref row);
}
}
}
@ -417,8 +418,8 @@ namespace dnSpy.AsmEditor.Compiler {
newSig = PatchCallingConventionSignature(callConvSigDict, sig);
if (newSig != sig) {
var row = tablesHeap.PropertyTable.Get(i + 1);
row.Type = newSig;
tablesHeap.PropertyTable.Set(i + 1, row);
row = new RawPropertyRow(row.PropFlags, row.Name, newSig);
tablesHeap.PropertyTable.Set(i + 1, ref row);
}
}
}
@ -433,9 +434,8 @@ namespace dnSpy.AsmEditor.Compiler {
sig = column.Size == 2 ? *(ushort*)p : *(uint*)p;
newSig = PatchTypeSignature(typeSigDict, sig);
if (newSig != sig) {
var row = tablesHeap.TypeSpecTable.Get(i + 1);
row.Signature = newSig;
tablesHeap.TypeSpecTable.Set(i + 1, row);
var row = new RawTypeSpecRow(newSig);
tablesHeap.TypeSpecTable.Set(i + 1, ref row);
}
}
}
@ -453,8 +453,8 @@ namespace dnSpy.AsmEditor.Compiler {
continue;
if (remappedTypeTokens.TryGetValue(token.Raw, out newToken)) {
var row = tablesHeap.GenericParamTable.Get(i + 1);
row.Kind = CodedToken.TypeDefOrRef.Encode(newToken);
tablesHeap.GenericParamTable.Set(i + 1, row);
row = new RawGenericParamRow(row.Number, row.Flags, row.Owner, row.Name, CodedToken.TypeDefOrRef.Encode(newToken));
tablesHeap.GenericParamTable.Set(i + 1, ref row);
}
}
}
@ -472,8 +472,8 @@ namespace dnSpy.AsmEditor.Compiler {
continue;
if (remappedTypeTokens.TryGetValue(token.Raw, out newToken)) {
var row = tablesHeap.GenericParamConstraintTable.Get(i + 1);
row.Constraint = CodedToken.TypeDefOrRef.Encode(newToken);
tablesHeap.GenericParamConstraintTable.Set(i + 1, row);
row = new RawGenericParamConstraintRow(row.Owner, CodedToken.TypeDefOrRef.Encode(newToken));
tablesHeap.GenericParamConstraintTable.Set(i + 1, ref row);
}
}
}
@ -526,25 +526,19 @@ namespace dnSpy.AsmEditor.Compiler {
return;
uint ivtTypeRefRid = mdEditor.TablesHeap.TypeRefTable.Create();
var ivtTypeRefRow = mdEditor.TablesHeap.TypeRefTable.Get(ivtTypeRefRid);
ivtTypeRefRow.Name = mdEditor.StringsHeap.Create("InternalsVisibleToAttribute");
ivtTypeRefRow.Namespace = mdEditor.StringsHeap.Create("System.Runtime.CompilerServices");
ivtTypeRefRow.ResolutionScope = corlibEncodedToken;
mdEditor.TablesHeap.TypeRefTable.Set(ivtTypeRefRid, ivtTypeRefRow);
var ivtTypeRefRow = new RawTypeRefRow(corlibEncodedToken, mdEditor.StringsHeap.Create("InternalsVisibleToAttribute"), mdEditor.StringsHeap.Create("System.Runtime.CompilerServices"));
mdEditor.TablesHeap.TypeRefTable.Set(ivtTypeRefRid, ref ivtTypeRefRow);
uint ivtCtorRid = mdEditor.TablesHeap.MemberRefTable.Create();
var ivtCtorRow = mdEditor.TablesHeap.MemberRefTable.Get(ivtCtorRid);
ivtCtorRow.Class = CodedToken.MemberRefParent.Encode(new MDToken(Table.TypeRef, ivtTypeRefRid));
ivtCtorRow.Name = mdEditor.StringsHeap.Create(".ctor");
ivtCtorRow.Signature = mdEditor.BlobHeap.Create(ivtCtorSigBlob);
mdEditor.TablesHeap.MemberRefTable.Set(ivtCtorRid, ivtCtorRow);
var ivtCtorRow = new RawMemberRefRow(CodedToken.MemberRefParent.Encode(new MDToken(Table.TypeRef, ivtTypeRefRid)),
mdEditor.StringsHeap.Create(".ctor"), mdEditor.BlobHeap.Create(ivtCtorSigBlob));
mdEditor.TablesHeap.MemberRefTable.Set(ivtCtorRid, ref ivtCtorRow);
uint ivtCARid = mdEditor.TablesHeap.CustomAttributeTable.Create();
var ivtCARow = mdEditor.TablesHeap.CustomAttributeTable.Get(ivtCARid);
ivtCARow.Parent = CodedToken.HasCustomAttribute.Encode(new MDToken(Table.Assembly, 1));
ivtCARow.Type = CodedToken.CustomAttributeType.Encode(new MDToken(Table.MemberRef, ivtCtorRid));
ivtCARow.Value = mdEditor.BlobHeap.Create(MDPatcherUtils.CreateIVTBlob(tempAssembly));
mdEditor.TablesHeap.CustomAttributeTable.Set(ivtCARid, ivtCARow);
var ivtCARow = new RawCustomAttributeRow(CodedToken.HasCustomAttribute.Encode(new MDToken(Table.Assembly, 1)),
CodedToken.CustomAttributeType.Encode(new MDToken(Table.MemberRef, ivtCtorRid)),
mdEditor.BlobHeap.Create(MDPatcherUtils.CreateIVTBlob(tempAssembly)));
mdEditor.TablesHeap.CustomAttributeTable.Set(ivtCARid, ref ivtCARow);
}
static readonly byte[] ivtCtorSigBlob = new byte[] { 0x20, 0x01, 0x01, 0x0E };

View File

@ -95,9 +95,9 @@ namespace dnSpy.AsmEditor.Compiler {
return false;
}
public static IMetaData TryCreateMetadata(RawModuleBytes moduleData, bool isFileLayout) {
public static Metadata TryCreateMetadata(RawModuleBytes moduleData, bool isFileLayout) {
try {
return MetaDataCreator.CreateMetaData(new PEImage((IntPtr)moduleData.Pointer, moduleData.Size, isFileLayout ? ImageLayout.File : ImageLayout.Memory, verify: true));
return MetadataCreator.CreateMetadata(new PEImage((IntPtr)moduleData.Pointer, moduleData.Size, isFileLayout ? ImageLayout.File : ImageLayout.Memory, verify: true));
}
catch (IOException) {
}

View File

@ -174,7 +174,7 @@ namespace dnSpy.AsmEditor.Compiler {
try {
using (var module = ModuleDefMD.Load(filename)) {
// It's a .NET file, return all bytes
var bytes = module.MetaData.PEImage.CreateFullStream().ReadAllBytes();
var bytes = module.Metadata.PEImage.CreateFullStream().ReadAllBytes();
var asm = module.Assembly?.ToAssemblyRef();
var debugFile = GetDebugFile(module);
return new ModuleResult(asm, bytes, debugFile);

View File

@ -93,8 +93,8 @@ namespace dnSpy.AsmEditor.Compiler {
}
(RawModuleBytes rawData, bool isFileLayout) TryReadModule(ModuleDefMD module) {
using (var stream = module.MetaData.PEImage.CreateFullStream())
return TryReadStream(stream, module.MetaData.PEImage.IsFileImageLayout);
using (var stream = module.Metadata.PEImage.CreateFullStream())
return TryReadStream(stream, module.Metadata.PEImage.IsFileImageLayout);
}
(RawModuleBytes rawData, bool isFileLayout) TryReadStream(IImageStream stream, bool isFileLayout) {

View File

@ -557,7 +557,7 @@ namespace dnSpy.AsmEditor.Hex {
var mod = context.Nodes[0].GetModule() as ModuleDefMD;
if (mod == null)
return null;
var pe = mod.MetaData.PEImage;
var pe = mod.Metadata.PEImage;
if (context.Nodes[0] is ImageSectionHeaderNode sectNode) {
if (sectNode.SectionNumber >= pe.ImageSectionHeaders.Count)
@ -567,11 +567,11 @@ namespace dnSpy.AsmEditor.Hex {
}
if (context.Nodes[0] is StorageStreamNode stgNode) {
if (stgNode.StreamNumber >= mod.MetaData.MetaDataHeader.StreamHeaders.Count)
if (stgNode.StreamNumber >= mod.Metadata.MetadataHeader.StreamHeaders.Count)
return null;
var sh = mod.MetaData.MetaDataHeader.StreamHeaders[stgNode.StreamNumber];
var sh = mod.Metadata.MetadataHeader.StreamHeaders[stgNode.StreamNumber];
return new AddressReference(mod.Location, false, (ulong)mod.MetaData.MetaDataHeader.StartOffset + sh.Offset, sh.StreamSize);
return new AddressReference(mod.Location, false, (ulong)mod.Metadata.MetadataHeader.StartOffset + sh.Offset, sh.StreamSize);
}
return null;
@ -1344,7 +1344,7 @@ namespace dnSpy.AsmEditor.Hex {
return string.Empty;
if (module is ModuleDefMD md) {
var mdToken = new MDToken(token);
var table = md.MetaData.TablesStream.Get(mdToken.Table);
var table = md.Metadata.TablesStream.Get(mdToken.Table);
if (table?.IsValidRID(mdToken.Rid) == true)
return string.Empty;
}

View File

@ -30,8 +30,8 @@ namespace dnSpy.AsmEditor.Hex {
return 0;
try {
using (var reader = mod.MetaData.PEImage.CreateFullStream()) {
reader.Position = (long)mod.MetaData.PEImage.ToFileOffset(md.RVA);
using (var reader = mod.Metadata.PEImage.CreateFullStream()) {
reader.Position = (long)mod.Metadata.PEImage.ToFileOffset(md.RVA);
var start = reader.Position;
if (!ReadHeader(reader, out ushort flags, out uint codeSize))
return 0;

View File

@ -50,7 +50,7 @@ namespace dnSpy.AsmEditor.Hex {
var lv = d as ListView;
if (lv == null)
return;
if (!(lv.DataContext is MetaDataTableVM))
if (!(lv.DataContext is MetadataTableVM))
return;
lv.InputBindings.Add(new KeyBinding(new CtxMenuMDTableCommandProxy(documentTabService, new SortMDTableCommand.TheMenuMDTableCommand()), Key.T, ModifierKeys.Shift | ModifierKeys.Control));
@ -66,16 +66,16 @@ namespace dnSpy.AsmEditor.Hex {
sealed class MDTableContext {
public ListView ListView { get; }
public MetaDataTableVM MetaDataTableVM { get; }
public MetaDataTableNode Node { get; }
public MetaDataTableRecordVM[] Records { get; }
public MetadataTableVM MetadataTableVM { get; }
public MetadataTableNode Node { get; }
public MetadataTableRecordVM[] Records { get; }
public bool IsContextMenu { get; }
public MDTableContext(ListView listView, MetaDataTableVM mdVM, MetaDataTableNode mdNode, bool isContextMenu) {
public MDTableContext(ListView listView, MetadataTableVM mdVM, MetadataTableNode mdNode, bool isContextMenu) {
ListView = listView;
MetaDataTableVM = mdVM;
MetadataTableVM = mdVM;
Node = mdNode;
Records = listView.SelectedItems.Cast<MetaDataTableRecordVM>().OrderBy(a => a.Span.Start).ToArray();
Records = listView.SelectedItems.Cast<MetadataTableRecordVM>().OrderBy(a => a.Span.Start).ToArray();
IsContextMenu = isContextMenu;
}
@ -158,11 +158,11 @@ namespace dnSpy.AsmEditor.Hex {
internal static MDTableContext ToMDTableContext(ListView listView, bool isContextMenu) {
if (listView == null)
return null;
var mdVM = listView.DataContext as MetaDataTableVM;
var mdVM = listView.DataContext as MetadataTableVM;
if (mdVM == null)
return null;
return new MDTableContext(listView, mdVM, (MetaDataTableNode)mdVM.Owner, isContextMenu);
return new MDTableContext(listView, mdVM, (MetadataTableNode)mdVM.Owner, isContextMenu);
}
}
@ -180,9 +180,9 @@ namespace dnSpy.AsmEditor.Hex {
}
static void ExecuteInternal(MDTableContext context) =>
SortTable(context.MetaDataTableVM, 1, context.MetaDataTableVM.Rows);
SortTable(context.MetadataTableVM, 1, context.MetadataTableVM.Rows);
internal static void SortTable(MetaDataTableVM mdTblVM, uint rid, uint count) {
internal static void SortTable(MetadataTableVM mdTblVM, uint rid, uint count) {
var buffer = mdTblVM.Buffer;
int len = (int)count * mdTblVM.TableInfo.RowSize;
var data = new byte[len];
@ -192,7 +192,7 @@ namespace dnSpy.AsmEditor.Hex {
HexBufferWriterHelper.Write(buffer, startOffset, data);
}
static bool IsEnabledInternal(MDTableContext context) => TableSorter.CanSort(context.MetaDataTableVM.TableInfo);
static bool IsEnabledInternal(MDTableContext context) => TableSorter.CanSort(context.MetadataTableVM.TableInfo);
}
static class SortSelectionMDTableCommand {
@ -211,11 +211,11 @@ namespace dnSpy.AsmEditor.Hex {
static void ExecuteInternal(MDTableContext context) {
uint rid = context.Records[0].Token.Rid;
uint count = (uint)context.Records.Length;
SortMDTableCommand.SortTable(context.MetaDataTableVM, rid, count);
SortMDTableCommand.SortTable(context.MetadataTableVM, rid, count);
}
static bool IsEnabledInternal(MDTableContext context) =>
TableSorter.CanSort(context.MetaDataTableVM.TableInfo) &&
TableSorter.CanSort(context.MetadataTableVM.TableInfo) &&
context.Records.Length > 1 &&
context.ContiguousRecords();
}
@ -237,16 +237,16 @@ namespace dnSpy.AsmEditor.Hex {
UIUtils.ScrollSelectAndSetFocus(context.ListView, recVM);
}
static MetaDataTableRecordVM Ask(string title, MDTableContext context) => MsgBox.Instance.Ask(dnSpy_AsmEditor_Resources.GoToMetaDataTableRow_RID, null, title, s => {
uint rid = SimpleTypeConverter.ParseUInt32(s, 1, context.MetaDataTableVM.Rows, out string error);
static MetadataTableRecordVM Ask(string title, MDTableContext context) => MsgBox.Instance.Ask(dnSpy_AsmEditor_Resources.GoToMetaDataTableRow_RID, null, title, s => {
uint rid = SimpleTypeConverter.ParseUInt32(s, 1, context.MetadataTableVM.Rows, out string error);
if (!string.IsNullOrEmpty(error))
return null;
return context.MetaDataTableVM.Get((int)(rid - 1));
return context.MetadataTableVM.Get((int)(rid - 1));
}, s => {
uint rid = SimpleTypeConverter.ParseUInt32(s, 1, context.MetaDataTableVM.Rows, out string error);
uint rid = SimpleTypeConverter.ParseUInt32(s, 1, context.MetadataTableVM.Rows, out string error);
if (!string.IsNullOrEmpty(error))
return error;
if (rid == 0 || rid > context.MetaDataTableVM.Rows)
if (rid == 0 || rid > context.MetadataTableVM.Rows)
return string.Format(dnSpy_AsmEditor_Resources.GoToRowIdentifier_InvalidRowIdentifier, rid);
return string.Empty;
});
@ -291,7 +291,7 @@ namespace dnSpy.AsmEditor.Hex {
var start = context.Records[0].Span.Start;
var end = context.Records[context.Records.Length - 1].Span.End;
return new AddressReference(context.MetaDataTableVM.Buffer.Name, false, start.ToUInt64(), (end - start).ToUInt64());
return new AddressReference(context.MetadataTableVM.Buffer.Name, false, start.ToUInt64(), (end - start).ToUInt64());
}
}
@ -340,14 +340,14 @@ namespace dnSpy.AsmEditor.Hex {
}
static void ExecuteInternal(MDTableContext context) {
var buffer = context.MetaDataTableVM.Buffer;
ulong totalSize = (ulong)context.MetaDataTableVM.TableInfo.RowSize * (ulong)context.Records.Length * 2;
var buffer = context.MetadataTableVM.Buffer;
ulong totalSize = (ulong)context.MetadataTableVM.TableInfo.RowSize * (ulong)context.Records.Length * 2;
if (totalSize >= int.MaxValue) {
MsgBox.Instance.Show(dnSpy_AsmEditor_Resources.TooManyBytesSelected);
return;
}
var sb = new StringBuilder((int)totalSize);
var recData = new byte[context.MetaDataTableVM.TableInfo.RowSize];
var recData = new byte[context.MetadataTableVM.TableInfo.RowSize];
foreach (var rec in context.Records) {
buffer.ReadBytes(rec.Span.Start, recData);
foreach (var b in recData)
@ -385,8 +385,8 @@ namespace dnSpy.AsmEditor.Hex {
if (data == null)
return;
var buffer = context.MetaDataTableVM.Buffer;
int recs = data.Length / context.MetaDataTableVM.TableInfo.RowSize;
var buffer = context.MetadataTableVM.Buffer;
int recs = data.Length / context.MetadataTableVM.TableInfo.RowSize;
HexBufferWriterHelper.Write(buffer, context.Records[0].Span.Start, data);
}
@ -400,11 +400,11 @@ namespace dnSpy.AsmEditor.Hex {
if (data == null || data.Length == 0)
return null;
if (data.Length % context.MetaDataTableVM.TableInfo.RowSize != 0)
if (data.Length % context.MetadataTableVM.TableInfo.RowSize != 0)
return null;
int recs = data.Length / context.MetaDataTableVM.TableInfo.RowSize;
if ((uint)context.Records[0].Index + (uint)recs > context.MetaDataTableVM.Rows)
int recs = data.Length / context.MetadataTableVM.TableInfo.RowSize;
if ((uint)context.Records[0].Index + (uint)recs > context.MetadataTableVM.Rows)
return null;
return data;
@ -414,7 +414,7 @@ namespace dnSpy.AsmEditor.Hex {
var data = GetPasteData(context);
if (data == null)
return null;
int recs = data.Length / context.MetaDataTableVM.TableInfo.RowSize;
int recs = data.Length / context.MetadataTableVM.TableInfo.RowSize;
if (recs <= 1)
return null;
return string.Format(dnSpy_AsmEditor_Resources.PasteRecordsCommand, recs, context.Records[0].Span.Start.ToUInt64(), context.Records[0].Token.Rid);

View File

@ -26,7 +26,7 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
sealed class HexDocumentTreeNodeDataFinder : IDocumentTreeNodeDataFinder {
public DocumentTreeNodeData FindNode(IDocumentTreeView documentTreeView, object @ref) => FindNode(documentTreeView, @ref as TokenReference);
internal static MetaDataTableRecordNode FindNode(IDocumentTreeView documentTreeView, TokenReference tokRef) {
internal static MetadataTableRecordNode FindNode(IDocumentTreeView documentTreeView, TokenReference tokRef) {
if (tokRef == null)
return null;

View File

@ -74,7 +74,7 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
}
public HexNode FindNode(HexVM structure, HexField field) {
Debug.Assert(!(structure is MetaDataTableRecordVM), "Use " + nameof(PENode) + "'s method instead");
Debug.Assert(!(structure is MetadataTableRecordVM), "Use " + nameof(PENode) + "'s method instead");
bool found = false;
foreach (var span in Spans) {
if (span.Contains(field.Span)) {

View File

@ -31,42 +31,42 @@ using dnSpy.Contracts.Text;
using dnSpy.Contracts.TreeView;
namespace dnSpy.AsmEditor.Hex.Nodes {
sealed class MetaDataTableNode : HexNode {
sealed class MetadataTableNode : HexNode {
public override Guid Guid => new Guid(DocumentTreeViewConstants.MDTBL_NODE_GUID);
public override NodePathName NodePathName => new NodePathName(Guid, ((byte)MetaDataTableVM.Table).ToString());
public override object VMObject => MetaDataTableVM;
public override NodePathName NodePathName => new NodePathName(Guid, ((byte)MetadataTableVM.Table).ToString());
public override object VMObject => MetadataTableVM;
protected override IEnumerable<HexVM> HexVMs {
get { yield return MetaDataTableVM; }
get { yield return MetadataTableVM; }
}
protected override ImageReference IconReference => DsImages.Metadata;
public override bool IsVirtualizingCollectionVM => true;
public MetaDataTableVM MetaDataTableVM { get; }
public MetadataTableVM MetadataTableVM { get; }
// It could have tens of thousands of children so prevent loading all of them when
// single-clicking the treenode
public override bool SingleClickExpandsChildren => false;
public TableInfo TableInfo { get; }
internal HexBuffer Buffer => MetaDataTableVM.Buffer;
internal HexBuffer Buffer => MetadataTableVM.Buffer;
public MetaDataTableNode(MetaDataTableVM mdTable)
public MetadataTableNode(MetadataTableVM mdTable)
: base(mdTable.Span) {
TableInfo = mdTable.TableInfo;
MetaDataTableVM = mdTable;
MetaDataTableVM.Owner = this;
MetadataTableVM = mdTable;
MetadataTableVM.Owner = this;
}
public override void Initialize() => TreeNode.LazyLoading = true;
protected override void WriteCore(ITextColorWriter output, DocumentNodeWriteOptions options) {
output.Write(BoxedTextColor.Number, string.Format("{0:X2}", (byte)MetaDataTableVM.Table));
output.Write(BoxedTextColor.Number, string.Format("{0:X2}", (byte)MetadataTableVM.Table));
output.WriteSpace();
output.Write(BoxedTextColor.HexTableName, string.Format("{0}", MetaDataTableVM.Table));
output.Write(BoxedTextColor.HexTableName, string.Format("{0}", MetadataTableVM.Table));
output.WriteSpace();
output.Write(BoxedTextColor.Punctuation, "(");
output.Write(BoxedTextColor.Number, string.Format("{0}", MetaDataTableVM.Rows));
output.Write(BoxedTextColor.Number, string.Format("{0}", MetadataTableVM.Rows));
output.Write(BoxedTextColor.Punctuation, ")");
}
@ -77,8 +77,8 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
decompiler.WriteCommentEnd(output, true);
output.WriteLine();
for (int i = 0; i < (int)MetaDataTableVM.Rows; i++) {
var obj = MetaDataTableVM.Get(i);
for (int i = 0; i < (int)MetadataTableVM.Rows; i++) {
var obj = MetadataTableVM.Get(i);
decompiler.WriteCommentBegin(output, true);
Write(output, obj);
decompiler.WriteCommentEnd(output, true);
@ -87,22 +87,22 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
}
public void WriteHeader(IDecompilerOutput output) {
var cols = MetaDataTableVM.TableInfo.Columns;
var cols = MetadataTableVM.TableInfo.Columns;
output.Write(string.Format("{0}\t{1}\t{2}", dnSpy_AsmEditor_Resources.RowIdentifier, dnSpy_AsmEditor_Resources.Token, dnSpy_AsmEditor_Resources.Offset), BoxedTextColor.Comment);
for (int i = 0; i < cols.Count; i++) {
output.Write("\t", BoxedTextColor.Comment);
output.Write(MetaDataTableVM.GetColumnName(i), BoxedTextColor.Comment);
output.Write(MetadataTableVM.GetColumnName(i), BoxedTextColor.Comment);
}
if (MetaDataTableVM.HasInfo) {
if (MetadataTableVM.HasInfo) {
output.Write("\t", BoxedTextColor.Comment);
output.Write(MetaDataTableVM.InfoName, BoxedTextColor.Comment);
output.Write(MetadataTableVM.InfoName, BoxedTextColor.Comment);
}
output.WriteLine();
}
public void Write(IDecompilerOutput output, MetaDataTableRecordVM mdVM) {
var cols = MetaDataTableVM.TableInfo.Columns;
public void Write(IDecompilerOutput output, MetadataTableRecordVM mdVM) {
var cols = MetadataTableVM.TableInfo.Columns;
output.Write(mdVM.RidString, BoxedTextColor.Comment);
output.Write("\t", BoxedTextColor.Comment);
@ -113,7 +113,7 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
output.Write("\t", BoxedTextColor.Comment);
output.Write(mdVM.GetField(j).DataFieldVM.StringValue, BoxedTextColor.Comment);
}
if (MetaDataTableVM.HasInfo) {
if (MetadataTableVM.HasInfo) {
output.Write("\t", BoxedTextColor.Comment);
output.Write(mdVM.Info, BoxedTextColor.Comment);
}
@ -124,9 +124,9 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
Debug.Assert(TreeNode.Children.Count == 0);
var pos = Span.Start;
ulong rowSize = (ulong)MetaDataTableVM.TableInfo.RowSize;
for (uint i = 0; i < MetaDataTableVM.Rows; i++) {
yield return new MetaDataTableRecordNode(TableInfo, (int)i, pos, pos + rowSize);
ulong rowSize = (ulong)MetadataTableVM.TableInfo.RowSize;
for (uint i = 0; i < MetadataTableVM.Rows; i++) {
yield return new MetadataTableRecordNode(TableInfo, (int)i, pos, pos + rowSize);
pos += rowSize;
}
}
@ -147,19 +147,19 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
int endi = (int)((end - 1 - Span.Start).ToUInt64() / (ulong)TableInfo.RowSize);
Debug.Assert(0 <= i && i <= endi && endi < TreeNode.Children.Count);
while (i <= endi) {
var obj = (MetaDataTableRecordNode)TreeNode.Children[i].Data;
var obj = (MetadataTableRecordNode)TreeNode.Children[i].Data;
obj.OnBufferChanged(changes);
i++;
}
}
}
public MetaDataTableRecordNode FindTokenNode(uint token) {
public MetadataTableRecordNode FindTokenNode(uint token) {
uint rid = token & 0x00FFFFFF;
if (rid - 1 >= MetaDataTableVM.Rows)
if (rid - 1 >= MetadataTableVM.Rows)
return null;
TreeNode.EnsureChildrenLoaded();
return (MetaDataTableRecordNode)TreeNode.Children[(int)rid - 1].Data;
return (MetadataTableRecordNode)TreeNode.Children[(int)rid - 1].Data;
}
}
}

View File

@ -29,7 +29,7 @@ using dnSpy.Contracts.Text;
using dnSpy.Contracts.Utilities;
namespace dnSpy.AsmEditor.Hex.Nodes {
sealed class MetaDataTableRecordNode : HexNode {
sealed class MetadataTableRecordNode : HexNode {
public override Guid Guid => new Guid(DocumentTreeViewConstants.MDTBLREC_NODE_GUID);
public override NodePathName NodePathName => new NodePathName(Guid, index.ToString());
public override object VMObject => Record;
@ -39,14 +39,14 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
}
protected override ImageReference IconReference => DsImages.Metadata;
MetaDataTableNode MDParent => (MetaDataTableNode)TreeNode.Parent.Data;
MetaDataTableRecordVM Record => MDParent.MetaDataTableVM.Get(index);
MetadataTableNode MDParent => (MetadataTableNode)TreeNode.Parent.Data;
MetadataTableRecordVM Record => MDParent.MetadataTableVM.Get(index);
public override bool SingleClickExpandsChildren => false;
readonly int index;
readonly Tuple<int[], Action<ITextColorWriter>> infoTuple;
public MetaDataTableRecordNode(TableInfo tableInfo, int index, HexPosition startOffset, HexPosition endOffset)
public MetadataTableRecordNode(TableInfo tableInfo, int index, HexPosition startOffset, HexPosition endOffset)
: base(HexSpan.FromBounds(startOffset, endOffset)) {
this.index = index;
infoTuple = GetInfoTuple(tableInfo);
@ -64,7 +64,7 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
public override void OnBufferChanged(NormalizedHexChangeCollection changes) {
if (infoTuple != null) {
var tableInfo = ((MetaDataTableNode)TreeNode.Parent.Data).TableInfo;
var tableInfo = ((MetadataTableNode)TreeNode.Parent.Data).TableInfo;
foreach (var index in infoTuple.Item1) {
var col = tableInfo.Columns[index];
var span = new HexSpan(Span.Start + (ulong)col.Offset, (ulong)col.Size);
@ -136,9 +136,9 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
}
string ReadStringsHeap(int index) {
var mdt = (MetaDataTableNode)TreeNode.Parent.Data;
var mdt = (MetadataTableNode)TreeNode.Parent.Data;
var tableInfo = mdt.TableInfo;
var s = SimpleTypeConverter.ToString(mdt.MetaDataTableVM.ReadStringsHeap(ReadFieldValue(mdt.Buffer, tableInfo.Columns[index])), false);
var s = SimpleTypeConverter.ToString(mdt.MetadataTableVM.ReadStringsHeap(ReadFieldValue(mdt.Buffer, tableInfo.Columns[index])), false);
Debug.Assert(s.Length >= 2);
if (s.Length < 2)
return s;

View File

@ -127,7 +127,7 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
return true;
}
public MetaDataTableRecordNode FindTokenNode(uint token) {
public MetadataTableRecordNode FindTokenNode(uint token) {
if ((token & 0x00FFFFFF) == 0)
return null;
TreeNode.EnsureChildrenLoaded();
@ -136,7 +136,7 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
}
public HexNode FindNode(HexVM structure, HexField field) {
if (structure is MetaDataTableRecordVM mdTblRecord)
if (structure is MetadataTableRecordVM mdTblRecord)
return FindTokenNode(mdTblRecord.Token.Raw);
TreeNode.EnsureChildrenLoaded();

View File

@ -65,7 +65,7 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
output.Write(HeapKind == DotNetHeapKind.Unknown ? BoxedTextColor.HexStorageStreamNameInvalid : BoxedTextColor.HexStorageStreamName, string.Format("{0}", storageStreamVM.RCNameVM.StringZ));
}
public MetaDataTableRecordNode FindTokenNode(uint token) {
public MetadataTableRecordNode FindTokenNode(uint token) {
if (HeapKind != DotNetHeapKind.Tables)
return null;
return ((TablesStreamNode)TreeNode.Children[0].Data).FindTokenNode(token);

View File

@ -48,9 +48,9 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
tablesStreamVM = tablesStream;
newChildren = new List<TreeNodeData>();
foreach (var mdTable in tablesStream.MetaDataTables) {
foreach (var mdTable in tablesStream.MetadataTables) {
if (mdTable != null)
newChildren.Add(new MetaDataTableNode(mdTable));
newChildren.Add(new MetadataTableNode(mdTable));
}
}
List<TreeNodeData> newChildren;
@ -71,8 +71,8 @@ namespace dnSpy.AsmEditor.Hex.Nodes {
protected override void WriteCore(ITextColorWriter output, DocumentNodeWriteOptions options) =>
output.Write(BoxedTextColor.HexTablesStream, dnSpy_AsmEditor_Resources.HexNode_TablesStream);
public MetaDataTableRecordNode FindTokenNode(uint token) {
var mdTblNode = (MetaDataTableNode)TreeNode.DataChildren.FirstOrDefault(a => ((MetaDataTableNode)a).TableInfo.Table == (Table)(token >> 24));
public MetadataTableRecordNode FindTokenNode(uint token) {
var mdTblNode = (MetadataTableNode)TreeNode.DataChildren.FirstOrDefault(a => ((MetadataTableNode)a).TableInfo.Table == (Table)(token >> 24));
return mdTblNode?.FindTokenNode(token);
}
}

View File

@ -1285,12 +1285,12 @@
<Label Grid.Row="2" Grid.Column="1" Margin="5 5 0 0" Target="{Binding ElementName=MinorRuntimeVersionVMTextBox}" Content="{Binding MinorRuntimeVersionVM.NameUI, Mode=OneTime}" />
<TextBox Grid.Row="2" Grid.Column="2" Margin="5 5 0 0" Name="MinorRuntimeVersionVMTextBox" Text="{Binding MinorRuntimeVersionVM.DataFieldVM.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=LostFocus}" />
<TextBox Grid.Row="3" Grid.Column="0" Margin="0 5 0 0" Style="{StaticResource MDTableTextBoxReadOnlyStyle}" Background="Transparent" Text="{Binding MetaDataVM.RVAVM.OffsetString, Mode=OneTime}" IsTabStop="False" />
<Label Grid.Row="3" Grid.Column="1" Margin="5 5 0 0" Target="{Binding ElementName=MetaDataVMRVAVMTextBox}" Content="{Binding MetaDataVM.RVAVM.NameUI, Mode=OneTime}" />
<TextBox Grid.Row="3" Grid.Column="2" Margin="5 5 0 0" Name="MetaDataVMRVAVMTextBox" Text="{Binding MetaDataVM.RVAVM.DataFieldVM.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=LostFocus}" />
<TextBox Grid.Row="4" Grid.Column="0" Margin="0 5 0 0" Style="{StaticResource MDTableTextBoxReadOnlyStyle}" Background="Transparent" Text="{Binding MetaDataVM.SizeVM.OffsetString, Mode=OneTime}" IsTabStop="False" />
<Label Grid.Row="4" Grid.Column="1" Margin="5 5 0 0" Target="{Binding ElementName=MetaDataVMSizeVMTextBox}" Content="{Binding MetaDataVM.SizeVM.NameUI, Mode=OneTime}" />
<TextBox Grid.Row="4" Grid.Column="2" Margin="5 5 0 0" Name="MetaDataVMSizeVMTextBox" Text="{Binding MetaDataVM.SizeVM.DataFieldVM.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=LostFocus}" />
<TextBox Grid.Row="3" Grid.Column="0" Margin="0 5 0 0" Style="{StaticResource MDTableTextBoxReadOnlyStyle}" Background="Transparent" Text="{Binding MetadataVM.RVAVM.OffsetString, Mode=OneTime}" IsTabStop="False" />
<Label Grid.Row="3" Grid.Column="1" Margin="5 5 0 0" Target="{Binding ElementName=MetadataVMRVAVMTextBox}" Content="{Binding MetadataVM.RVAVM.NameUI, Mode=OneTime}" />
<TextBox Grid.Row="3" Grid.Column="2" Margin="5 5 0 0" Name="MetadataVMRVAVMTextBox" Text="{Binding MetadataVM.RVAVM.DataFieldVM.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=LostFocus}" />
<TextBox Grid.Row="4" Grid.Column="0" Margin="0 5 0 0" Style="{StaticResource MDTableTextBoxReadOnlyStyle}" Background="Transparent" Text="{Binding MetadataVM.SizeVM.OffsetString, Mode=OneTime}" IsTabStop="False" />
<Label Grid.Row="4" Grid.Column="1" Margin="5 5 0 0" Target="{Binding ElementName=MetadataVMSizeVMTextBox}" Content="{Binding MetadataVM.SizeVM.NameUI, Mode=OneTime}" />
<TextBox Grid.Row="4" Grid.Column="2" Margin="5 5 0 0" Name="MetadataVMSizeVMTextBox" Text="{Binding MetadataVM.SizeVM.DataFieldVM.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=LostFocus}" />
<TextBox Grid.Row="5" Grid.Column="0" Margin="0 5 0 0" Style="{StaticResource MDTableTextBoxReadOnlyStyle}" Background="Transparent" Text="{Binding FlagsVM.OffsetString, Mode=OneTime}" IsTabStop="False" />
<Label Grid.Row="5" Grid.Column="1" Margin="5 5 0 0" Target="{Binding ElementName=FlagsVMTextBox}" Content="{Binding FlagsVM.NameUI, Mode=OneTime}" />
@ -2168,7 +2168,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable1VM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable1VM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
VirtualizingStackPanel.IsVirtualizing="True"
@ -2217,7 +2217,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable2VM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable2VM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
VirtualizingStackPanel.IsVirtualizing="True"
@ -2273,7 +2273,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable3VM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable3VM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
VirtualizingStackPanel.IsVirtualizing="True"
@ -2336,7 +2336,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable4VM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable4VM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
VirtualizingStackPanel.IsVirtualizing="True"
@ -2406,7 +2406,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable5VM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable5VM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
VirtualizingStackPanel.IsVirtualizing="True"
@ -2483,7 +2483,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable6VM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable6VM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
VirtualizingStackPanel.IsVirtualizing="True"
@ -2567,7 +2567,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable9VM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable9VM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
VirtualizingStackPanel.IsVirtualizing="True"
@ -2672,7 +2672,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable1InfoVM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable1InfoVM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
ScrollViewer.IsDeferredScrollingEnabled="True"
@ -2729,7 +2729,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable2InfoVM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable2InfoVM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
ScrollViewer.IsDeferredScrollingEnabled="True"
@ -2793,7 +2793,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable3InfoVM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable3InfoVM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
ScrollViewer.IsDeferredScrollingEnabled="True"
@ -2864,7 +2864,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable4InfoVM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable4InfoVM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
ScrollViewer.IsDeferredScrollingEnabled="True"
@ -2942,7 +2942,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable5InfoVM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable5InfoVM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
ScrollViewer.IsDeferredScrollingEnabled="True"
@ -3027,7 +3027,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable6InfoVM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable6InfoVM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
ScrollViewer.IsDeferredScrollingEnabled="True"
@ -3119,7 +3119,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTable9InfoVM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTable9InfoVM}">
<Border TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<ListView
ScrollViewer.IsDeferredScrollingEnabled="True"
@ -3232,7 +3232,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:MetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.Resources>
@ -3304,7 +3304,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:TypeDefMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:TypeDefMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -3410,7 +3410,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:FieldMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:FieldMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -3488,7 +3488,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MethodMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:MethodMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -3631,7 +3631,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:ParamMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:ParamMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -3687,7 +3687,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:DeclSecurityMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:DeclSecurityMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -3738,7 +3738,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:EventMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:EventMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -3787,7 +3787,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:PropertyMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:PropertyMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -3837,7 +3837,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:MethodSemanticsMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:MethodSemanticsMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -3892,7 +3892,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:ImplMapMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:ImplMapMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -3971,7 +3971,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:AssemblyMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:AssemblyMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -4095,7 +4095,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:AssemblyRefMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:AssemblyRefMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -4203,7 +4203,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:FileMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:FileMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -4251,7 +4251,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:ExportedTypeMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:ExportedTypeMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -4351,7 +4351,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:ManifestResourceMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:ManifestResourceMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -4408,7 +4408,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:GenericParamMetaDataTableRecordV11VM}">
<DataTemplate DataType="{x:Type tnhex:GenericParamMetadataTableRecordV11VM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
@ -4488,7 +4488,7 @@
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type tnhex:GenericParamMetaDataTableRecordVM}">
<DataTemplate DataType="{x:Type tnhex:GenericParamMetadataTableRecordVM}">
<Border mvvm:InitDataTemplateAP.Initialize="True" TextBlock.Foreground="{DynamicResource PEHexForeground}" Background="{DynamicResource PEHexBackground}" BorderBrush="{DynamicResource PEHexBorder}" BorderThickness="1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>

View File

@ -86,8 +86,8 @@ namespace dnSpy.AsmEditor.Hex.PE {
var tblsStream = peStructureProvider.TablesStream;
if (tblsStream != null) {
var first = tblsStream.MetaDataTables.FirstOrDefault(a => a != null);
var last = tblsStream.MetaDataTables.LastOrDefault(a => a != null);
var first = tblsStream.MetadataTables.FirstOrDefault(a => a != null);
var last = tblsStream.MetadataTables.LastOrDefault(a => a != null);
Debug.Assert(first != null);
if (first != null)
metadataTablesSpan = HexSpan.FromBounds(first.Span.Start, last.Span.End);
@ -104,7 +104,7 @@ namespace dnSpy.AsmEditor.Hex.PE {
}
}
if (metadataTablesSpan.Contains(position)) {
foreach (var mdTbl in peStructureProvider.TablesStream.MetaDataTables) {
foreach (var mdTbl in peStructureProvider.TablesStream.MetadataTables) {
if (mdTbl == null || !mdTbl.Span.Contains(position))
continue;
var offset = position - mdTbl.Span.Start;

View File

@ -28,7 +28,7 @@ namespace dnSpy.AsmEditor.Hex.PE {
public UInt32HexField CbVM { get; }
public UInt16HexField MajorRuntimeVersionVM { get; }
public UInt16HexField MinorRuntimeVersionVM { get; }
public DataDirectoryVM MetaDataVM { get; }
public DataDirectoryVM MetadataVM { get; }
public UInt32FlagsHexField FlagsVM { get; }
public UInt32HexField EntryPointTokenRVAVM { get; }
public DataDirectoryVM ResourcesVM { get; }
@ -47,7 +47,7 @@ namespace dnSpy.AsmEditor.Hex.PE {
CbVM = new UInt32HexField(cor20.Cb);
MajorRuntimeVersionVM = new UInt16HexField(cor20.MajorRuntimeVersion, true);
MinorRuntimeVersionVM = new UInt16HexField(cor20.MinorRuntimeVersion, true);
MetaDataVM = new DataDirectoryVM(cor20.MetaData);
MetadataVM = new DataDirectoryVM(cor20.Metadata);
FlagsVM = new UInt32FlagsHexField(cor20.Flags);
FlagsVM.Add(new BooleanHexBitField(dnSpy_AsmEditor_Resources.HexNode_Cor20Header_Flags_IL_Only, 0));
FlagsVM.Add(new BooleanHexBitField(dnSpy_AsmEditor_Resources.HexNode_Cor20Header_Flags_32BitReqd, 1));
@ -68,8 +68,8 @@ namespace dnSpy.AsmEditor.Hex.PE {
CbVM,
MajorRuntimeVersionVM,
MinorRuntimeVersionVM,
MetaDataVM.RVAVM,
MetaDataVM.SizeVM,
MetadataVM.RVAVM,
MetadataVM.SizeVM,
FlagsVM,
EntryPointTokenRVAVM,
ResourcesVM.RVAVM,

View File

@ -25,7 +25,7 @@ using dnSpy.Contracts.Hex.Files.DotNet;
using dnSpy.Contracts.Utilities;
namespace dnSpy.AsmEditor.Hex.PE {
abstract class MetaDataTableRecordVM : HexVM, IVirtualizedListItem {
abstract class MetadataTableRecordVM : HexVM, IVirtualizedListItem {
public int Index => (int)mdToken.Rid - 1;
public override string Name => string.Format("{0}[{1:X6}]", mdToken.Table, mdToken.Rid);
public string OffsetString => string.Format("0x{0:X8}", Span.Start.ToUInt64());
@ -170,10 +170,10 @@ namespace dnSpy.AsmEditor.Hex.PE {
Guid? ReadGuidHeap(HexField field) => mdVM.ReadGuidHeap(ReadFieldValue(field));
MetaDataTableRecordVM GetMetaDataTableRecordVM(Table table, uint rid) {
MetadataTableRecordVM GetMetadataTableRecordVM(Table table, uint rid) {
if (rid == 0)
return null;
var tblVM = mdVM.TablesStream.TryGetMetaDataTable(table);
var tblVM = mdVM.TablesStream.TryGetMetadataTable(table);
if (tblVM == null)
return null;
if (rid - 1 >= (uint)tblVM.Collection.Count)
@ -196,7 +196,7 @@ namespace dnSpy.AsmEditor.Hex.PE {
}
string GetInfo(Table table, uint rid) {
var recVM = GetMetaDataTableRecordVM(table, rid);
var recVM = GetMetadataTableRecordVM(table, rid);
return recVM?.Info ?? string.Empty;
}
@ -313,11 +313,11 @@ namespace dnSpy.AsmEditor.Hex.PE {
public virtual string Info => string.Empty;
protected virtual int[] InfoColumnIndexes => null;
protected readonly MetaDataTableVM mdVM;
protected readonly MetadataTableVM mdVM;
MDToken mdToken;
readonly HexField[] hexFields;
protected MetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
protected MetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(new HexSpan(mdVM.Span.Start + (mdToken.Rid - 1) * (ulong)mdVM.TableInfo.RowSize, (ulong)mdVM.TableInfo.RowSize)) {
this.mdVM = mdVM;
this.mdToken = mdToken;
@ -360,8 +360,8 @@ namespace dnSpy.AsmEditor.Hex.PE {
}
}
sealed class ModuleMetaDataTableRecordVM : MetaDataTableRecordVM {
public ModuleMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ModuleMetadataTableRecordVM : MetadataTableRecordVM {
public ModuleMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -370,8 +370,8 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 1 };
}
sealed class TypeRefMetaDataTableRecordVM : MetaDataTableRecordVM {
public TypeRefMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class TypeRefMetadataTableRecordVM : MetadataTableRecordVM {
public TypeRefMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -381,8 +381,8 @@ namespace dnSpy.AsmEditor.Hex.PE {
public static string CreateTypeString(string ns, string name) => string.IsNullOrEmpty(ns) ? name : string.Format("{0}.{1}", ns, name);
}
sealed class TypeDefMetaDataTableRecordVM : MetaDataTableRecordVM {
public TypeDefMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class TypeDefMetadataTableRecordVM : MetadataTableRecordVM {
public TypeDefMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -448,19 +448,19 @@ namespace dnSpy.AsmEditor.Hex.PE {
return field;
}
public override string Info => TypeRefMetaDataTableRecordVM.CreateTypeString(ReadStringsHeap(Column2), ReadStringsHeap(Column1));
public override string Info => TypeRefMetadataTableRecordVM.CreateTypeString(ReadStringsHeap(Column2), ReadStringsHeap(Column1));
protected override int[] InfoColumnIndexes => infoColIndexes;
static readonly int[] infoColIndexes = new int[] { 1, 2 };
}
sealed class FieldPtrMetaDataTableRecordVM : MetaDataTableRecordVM {
public FieldPtrMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class FieldPtrMetadataTableRecordVM : MetadataTableRecordVM {
public FieldPtrMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class FieldMetaDataTableRecordVM : MetaDataTableRecordVM {
public FieldMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class FieldMetadataTableRecordVM : MetadataTableRecordVM {
public FieldMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -498,14 +498,14 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 1 };
}
sealed class MethodPtrMetaDataTableRecordVM : MetaDataTableRecordVM {
public MethodPtrMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class MethodPtrMetadataTableRecordVM : MetadataTableRecordVM {
public MethodPtrMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class MethodMetaDataTableRecordVM : MetaDataTableRecordVM {
public MethodMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class MethodMetadataTableRecordVM : MetadataTableRecordVM {
public MethodMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -576,14 +576,14 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 3 };
}
sealed class ParamPtrMetaDataTableRecordVM : MetaDataTableRecordVM {
public ParamPtrMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ParamPtrMetadataTableRecordVM : MetadataTableRecordVM {
public ParamPtrMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class ParamMetaDataTableRecordVM : MetaDataTableRecordVM {
public ParamMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ParamMetadataTableRecordVM : MetadataTableRecordVM {
public ParamMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -607,14 +607,14 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 2 };
}
sealed class InterfaceImplMetaDataTableRecordVM : MetaDataTableRecordVM {
public InterfaceImplMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class InterfaceImplMetadataTableRecordVM : MetadataTableRecordVM {
public InterfaceImplMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class MemberRefMetaDataTableRecordVM : MetaDataTableRecordVM {
public MemberRefMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class MemberRefMetadataTableRecordVM : MetadataTableRecordVM {
public MemberRefMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -623,26 +623,26 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 1 };
}
sealed class ConstantMetaDataTableRecordVM : MetaDataTableRecordVM {
public ConstantMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ConstantMetadataTableRecordVM : MetadataTableRecordVM {
public ConstantMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class CustomAttributeMetaDataTableRecordVM : MetaDataTableRecordVM {
public CustomAttributeMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class CustomAttributeMetadataTableRecordVM : MetadataTableRecordVM {
public CustomAttributeMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class FieldMarshalMetaDataTableRecordVM : MetaDataTableRecordVM {
public FieldMarshalMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class FieldMarshalMetadataTableRecordVM : MetadataTableRecordVM {
public FieldMarshalMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class DeclSecurityMetaDataTableRecordVM : MetaDataTableRecordVM {
public DeclSecurityMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class DeclSecurityMetadataTableRecordVM : MetadataTableRecordVM {
public DeclSecurityMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -675,38 +675,38 @@ namespace dnSpy.AsmEditor.Hex.PE {
}
}
sealed class ClassLayoutMetaDataTableRecordVM : MetaDataTableRecordVM {
public ClassLayoutMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ClassLayoutMetadataTableRecordVM : MetadataTableRecordVM {
public ClassLayoutMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class FieldLayoutMetaDataTableRecordVM : MetaDataTableRecordVM {
public FieldLayoutMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class FieldLayoutMetadataTableRecordVM : MetadataTableRecordVM {
public FieldLayoutMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class StandAloneSigMetaDataTableRecordVM : MetaDataTableRecordVM {
public StandAloneSigMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class StandAloneSigMetadataTableRecordVM : MetadataTableRecordVM {
public StandAloneSigMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class EventMapMetaDataTableRecordVM : MetaDataTableRecordVM {
public EventMapMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class EventMapMetadataTableRecordVM : MetadataTableRecordVM {
public EventMapMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class EventPtrMetaDataTableRecordVM : MetaDataTableRecordVM {
public EventPtrMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class EventPtrMetadataTableRecordVM : MetadataTableRecordVM {
public EventPtrMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class EventMetaDataTableRecordVM : MetaDataTableRecordVM {
public EventMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class EventMetadataTableRecordVM : MetadataTableRecordVM {
public EventMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -725,20 +725,20 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 1 };
}
sealed class PropertyMapMetaDataTableRecordVM : MetaDataTableRecordVM {
public PropertyMapMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class PropertyMapMetadataTableRecordVM : MetadataTableRecordVM {
public PropertyMapMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class PropertyPtrMetaDataTableRecordVM : MetaDataTableRecordVM {
public PropertyPtrMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class PropertyPtrMetadataTableRecordVM : MetadataTableRecordVM {
public PropertyPtrMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class PropertyMetaDataTableRecordVM : MetaDataTableRecordVM {
public PropertyMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class PropertyMetadataTableRecordVM : MetadataTableRecordVM {
public PropertyMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -758,8 +758,8 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 1 };
}
sealed class MethodSemanticsMetaDataTableRecordVM : MetaDataTableRecordVM {
public MethodSemanticsMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class MethodSemanticsMetadataTableRecordVM : MetadataTableRecordVM {
public MethodSemanticsMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -778,14 +778,14 @@ namespace dnSpy.AsmEditor.Hex.PE {
}
}
sealed class MethodImplMetaDataTableRecordVM : MetaDataTableRecordVM {
public MethodImplMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class MethodImplMetadataTableRecordVM : MetadataTableRecordVM {
public MethodImplMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class ModuleRefMetaDataTableRecordVM : MetaDataTableRecordVM {
public ModuleRefMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ModuleRefMetadataTableRecordVM : MetadataTableRecordVM {
public ModuleRefMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -794,14 +794,14 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 0 };
}
sealed class TypeSpecMetaDataTableRecordVM : MetaDataTableRecordVM {
public TypeSpecMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class TypeSpecMetadataTableRecordVM : MetadataTableRecordVM {
public TypeSpecMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class ImplMapMetaDataTableRecordVM : MetaDataTableRecordVM {
public ImplMapMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ImplMapMetadataTableRecordVM : MetadataTableRecordVM {
public ImplMapMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -851,26 +851,26 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 2 };
}
sealed class FieldRVAMetaDataTableRecordVM : MetaDataTableRecordVM {
public FieldRVAMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class FieldRVAMetadataTableRecordVM : MetadataTableRecordVM {
public FieldRVAMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class ENCLogMetaDataTableRecordVM : MetaDataTableRecordVM {
public ENCLogMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ENCLogMetadataTableRecordVM : MetadataTableRecordVM {
public ENCLogMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class ENCMapMetaDataTableRecordVM : MetaDataTableRecordVM {
public ENCMapMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ENCMapMetadataTableRecordVM : MetadataTableRecordVM {
public ENCMapMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class AssemblyMetaDataTableRecordVM : MetaDataTableRecordVM {
public AssemblyMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class AssemblyMetadataTableRecordVM : MetadataTableRecordVM {
public AssemblyMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -935,14 +935,14 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 7 };
}
sealed class AssemblyProcessorMetaDataTableRecordVM : MetaDataTableRecordVM {
public AssemblyProcessorMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class AssemblyProcessorMetadataTableRecordVM : MetadataTableRecordVM {
public AssemblyProcessorMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class AssemblyOSMetaDataTableRecordVM : MetaDataTableRecordVM {
public AssemblyOSMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class AssemblyOSMetadataTableRecordVM : MetadataTableRecordVM {
public AssemblyOSMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -953,8 +953,8 @@ namespace dnSpy.AsmEditor.Hex.PE {
}
}
sealed class AssemblyRefMetaDataTableRecordVM : MetaDataTableRecordVM {
public AssemblyRefMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class AssemblyRefMetadataTableRecordVM : MetadataTableRecordVM {
public AssemblyRefMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -962,7 +962,7 @@ namespace dnSpy.AsmEditor.Hex.PE {
if (0 <= colInfo.Index && colInfo.Index <= 3)
return new UInt16HexField(mdVM.Buffer, Name, colInfo.Name, Span.Start + (uint)colInfo.Offset, true);
else if (colInfo.Index == 4)
return AssemblyMetaDataTableRecordVM.CreateAssemblyAttributesField(colInfo, mdVM.Buffer, Name, Span.Start);
return AssemblyMetadataTableRecordVM.CreateAssemblyAttributesField(colInfo, mdVM.Buffer, Name, Span.Start);
return base.CreateField(colInfo);
}
@ -971,14 +971,14 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 6 };
}
sealed class AssemblyRefProcessorMetaDataTableRecordVM : MetaDataTableRecordVM {
public AssemblyRefProcessorMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class AssemblyRefProcessorMetadataTableRecordVM : MetadataTableRecordVM {
public AssemblyRefProcessorMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class AssemblyRefOSMetaDataTableRecordVM : MetaDataTableRecordVM {
public AssemblyRefOSMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class AssemblyRefOSMetadataTableRecordVM : MetadataTableRecordVM {
public AssemblyRefOSMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -989,8 +989,8 @@ namespace dnSpy.AsmEditor.Hex.PE {
}
}
sealed class FileMetaDataTableRecordVM : MetaDataTableRecordVM {
public FileMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class FileMetadataTableRecordVM : MetadataTableRecordVM {
public FileMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -1008,24 +1008,24 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 1 };
}
sealed class ExportedTypeMetaDataTableRecordVM : MetaDataTableRecordVM {
public ExportedTypeMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ExportedTypeMetadataTableRecordVM : MetadataTableRecordVM {
public ExportedTypeMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
protected override HexField CreateField(ColumnInfo colInfo) {
if (colInfo.Index == 0)
return TypeDefMetaDataTableRecordVM.CreateTypeAttributesField(colInfo, mdVM.Buffer, Name, Span.Start);
return TypeDefMetadataTableRecordVM.CreateTypeAttributesField(colInfo, mdVM.Buffer, Name, Span.Start);
return base.CreateField(colInfo);
}
public override string Info => TypeRefMetaDataTableRecordVM.CreateTypeString(ReadStringsHeap(Column3), ReadStringsHeap(Column2));
public override string Info => TypeRefMetadataTableRecordVM.CreateTypeString(ReadStringsHeap(Column3), ReadStringsHeap(Column2));
protected override int[] InfoColumnIndexes => infoColIndexes;
static readonly int[] infoColIndexes = new int[] { 2, 3 };
}
sealed class ManifestResourceMetaDataTableRecordVM : MetaDataTableRecordVM {
public ManifestResourceMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ManifestResourceMetadataTableRecordVM : MetadataTableRecordVM {
public ManifestResourceMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -1048,20 +1048,20 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 2 };
}
sealed class NestedClassMetaDataTableRecordVM : MetaDataTableRecordVM {
public NestedClassMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class NestedClassMetadataTableRecordVM : MetadataTableRecordVM {
public NestedClassMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class GenericParamMetaDataTableRecordV11VM : MetaDataTableRecordVM {
public GenericParamMetaDataTableRecordV11VM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class GenericParamMetadataTableRecordV11VM : MetadataTableRecordVM {
public GenericParamMetadataTableRecordV11VM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
protected override HexField CreateField(ColumnInfo colInfo) {
if (colInfo.Index == 1)
return GenericParamMetaDataTableRecordVM.CreateGenericParamAttributesField(colInfo, mdVM.Buffer, Name, Span.Start);
return GenericParamMetadataTableRecordVM.CreateGenericParamAttributesField(colInfo, mdVM.Buffer, Name, Span.Start);
return base.CreateField(colInfo);
}
@ -1070,8 +1070,8 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 3 };
}
sealed class GenericParamMetaDataTableRecordVM : MetaDataTableRecordVM {
public GenericParamMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class GenericParamMetadataTableRecordVM : MetadataTableRecordVM {
public GenericParamMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
@ -1101,62 +1101,62 @@ namespace dnSpy.AsmEditor.Hex.PE {
static readonly int[] infoColIndexes = new int[] { 3 };
}
sealed class MethodSpecMetaDataTableRecordVM : MetaDataTableRecordVM {
public MethodSpecMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class MethodSpecMetadataTableRecordVM : MetadataTableRecordVM {
public MethodSpecMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class GenericParamConstraintMetaDataTableRecordVM : MetaDataTableRecordVM {
public GenericParamConstraintMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class GenericParamConstraintMetadataTableRecordVM : MetadataTableRecordVM {
public GenericParamConstraintMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class DocumentMetaDataTableRecordVM : MetaDataTableRecordVM {
public DocumentMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class DocumentMetadataTableRecordVM : MetadataTableRecordVM {
public DocumentMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class MethodDebugInformationMetaDataTableRecordVM : MetaDataTableRecordVM {
public MethodDebugInformationMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class MethodDebugInformationMetadataTableRecordVM : MetadataTableRecordVM {
public MethodDebugInformationMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class LocalScopeMetaDataTableRecordVM : MetaDataTableRecordVM {
public LocalScopeMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class LocalScopeMetadataTableRecordVM : MetadataTableRecordVM {
public LocalScopeMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class LocalVariableMetaDataTableRecordVM : MetaDataTableRecordVM {
public LocalVariableMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class LocalVariableMetadataTableRecordVM : MetadataTableRecordVM {
public LocalVariableMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class LocalConstantMetaDataTableRecordVM : MetaDataTableRecordVM {
public LocalConstantMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class LocalConstantMetadataTableRecordVM : MetadataTableRecordVM {
public LocalConstantMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class ImportScopeMetaDataTableRecordVM : MetaDataTableRecordVM {
public ImportScopeMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class ImportScopeMetadataTableRecordVM : MetadataTableRecordVM {
public ImportScopeMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class StateMachineMethodMetaDataTableRecordVM : MetaDataTableRecordVM {
public StateMachineMethodMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class StateMachineMethodMetadataTableRecordVM : MetadataTableRecordVM {
public StateMachineMethodMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}
sealed class CustomDebugInformationMetaDataTableRecordVM : MetaDataTableRecordVM {
public CustomDebugInformationMetaDataTableRecordVM(MetaDataTableVM mdVM, MDToken mdToken)
sealed class CustomDebugInformationMetadataTableRecordVM : MetadataTableRecordVM {
public CustomDebugInformationMetadataTableRecordVM(MetadataTableVM mdVM, MDToken mdToken)
: base(mdVM, mdToken) {
}
}

View File

@ -26,7 +26,7 @@ using dnSpy.Contracts.Hex;
using dnSpy.Contracts.Hex.Files.DotNet;
namespace dnSpy.AsmEditor.Hex.PE {
abstract class MetaDataTableVM : HexVM {
abstract class MetadataTableVM : HexVM {
public Table Table => TableInfo.Table;
public uint Rows { get; }
public TableInfo TableInfo { get; }
@ -54,7 +54,7 @@ namespace dnSpy.AsmEditor.Hex.PE {
public override IEnumerable<HexField> HexFields => hexFields;
readonly HexField[] hexFields = Array.Empty<HexField>();
public VirtualizedList<MetaDataTableRecordVM> Collection { get; }
public VirtualizedList<MetadataTableRecordVM> Collection { get; }
public object SelectedItem {
get => selectedItem;
@ -75,7 +75,7 @@ namespace dnSpy.AsmEditor.Hex.PE {
readonly HexSpan stringsHeapSpan;
readonly HexSpan guidHeapSpan;
protected MetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
protected MetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(mdTable.Span) {
this.buffer = buffer;
TablesStream = tablesStream;
@ -83,124 +83,124 @@ namespace dnSpy.AsmEditor.Hex.PE {
this.guidHeapSpan = guidHeapSpan;
Rows = mdTable.Rows;
TableInfo = CreateTableInfo(mdTable.TableInfo);
Collection = new VirtualizedList<MetaDataTableRecordVM>((int)Rows, CreateItem);
Collection = new VirtualizedList<MetadataTableRecordVM>((int)Rows, CreateItem);
}
MetaDataTableRecordVM CreateItem(int index) {
MetadataTableRecordVM CreateItem(int index) {
Debug.Assert(index >= 0 && (uint)index < Rows);
switch (TableInfo.Table) {
case Table.Module: return new ModuleMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.TypeRef: return new TypeRefMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.TypeDef: return new TypeDefMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.FieldPtr: return new FieldPtrMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Field: return new FieldMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MethodPtr: return new MethodPtrMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Method: return new MethodMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ParamPtr: return new ParamPtrMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Param: return new ParamMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.InterfaceImpl: return new InterfaceImplMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MemberRef: return new MemberRefMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Constant: return new ConstantMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.CustomAttribute: return new CustomAttributeMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.FieldMarshal: return new FieldMarshalMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.DeclSecurity: return new DeclSecurityMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ClassLayout: return new ClassLayoutMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.FieldLayout: return new FieldLayoutMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.StandAloneSig: return new StandAloneSigMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.EventMap: return new EventMapMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.EventPtr: return new EventPtrMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Event: return new EventMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.PropertyMap: return new PropertyMapMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.PropertyPtr: return new PropertyPtrMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Property: return new PropertyMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MethodSemantics: return new MethodSemanticsMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MethodImpl: return new MethodImplMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ModuleRef: return new ModuleRefMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.TypeSpec: return new TypeSpecMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ImplMap: return new ImplMapMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.FieldRVA: return new FieldRVAMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ENCLog: return new ENCLogMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ENCMap: return new ENCMapMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Assembly: return new AssemblyMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.AssemblyProcessor: return new AssemblyProcessorMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.AssemblyOS: return new AssemblyOSMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.AssemblyRef: return new AssemblyRefMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.AssemblyRefProcessor: return new AssemblyRefProcessorMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.AssemblyRefOS: return new AssemblyRefOSMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.File: return new FileMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ExportedType: return new ExportedTypeMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ManifestResource: return new ManifestResourceMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.NestedClass: return new NestedClassMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.GenericParam: return TableInfo.Columns.Count == 5 ? (MetaDataTableRecordVM)new GenericParamMetaDataTableRecordV11VM(this, new MDToken(TableInfo.Table, index + 1)) : new GenericParamMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MethodSpec: return new MethodSpecMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.GenericParamConstraint: return new GenericParamConstraintMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Document: return new DocumentMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MethodDebugInformation: return new MethodDebugInformationMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.LocalScope: return new LocalScopeMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.LocalVariable: return new LocalVariableMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.LocalConstant: return new LocalConstantMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ImportScope: return new ImportScopeMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.StateMachineMethod: return new StateMachineMethodMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.CustomDebugInformation: return new CustomDebugInformationMetaDataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Module: return new ModuleMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.TypeRef: return new TypeRefMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.TypeDef: return new TypeDefMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.FieldPtr: return new FieldPtrMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Field: return new FieldMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MethodPtr: return new MethodPtrMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Method: return new MethodMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ParamPtr: return new ParamPtrMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Param: return new ParamMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.InterfaceImpl: return new InterfaceImplMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MemberRef: return new MemberRefMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Constant: return new ConstantMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.CustomAttribute: return new CustomAttributeMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.FieldMarshal: return new FieldMarshalMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.DeclSecurity: return new DeclSecurityMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ClassLayout: return new ClassLayoutMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.FieldLayout: return new FieldLayoutMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.StandAloneSig: return new StandAloneSigMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.EventMap: return new EventMapMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.EventPtr: return new EventPtrMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Event: return new EventMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.PropertyMap: return new PropertyMapMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.PropertyPtr: return new PropertyPtrMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Property: return new PropertyMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MethodSemantics: return new MethodSemanticsMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MethodImpl: return new MethodImplMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ModuleRef: return new ModuleRefMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.TypeSpec: return new TypeSpecMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ImplMap: return new ImplMapMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.FieldRVA: return new FieldRVAMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ENCLog: return new ENCLogMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ENCMap: return new ENCMapMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Assembly: return new AssemblyMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.AssemblyProcessor: return new AssemblyProcessorMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.AssemblyOS: return new AssemblyOSMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.AssemblyRef: return new AssemblyRefMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.AssemblyRefProcessor: return new AssemblyRefProcessorMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.AssemblyRefOS: return new AssemblyRefOSMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.File: return new FileMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ExportedType: return new ExportedTypeMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ManifestResource: return new ManifestResourceMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.NestedClass: return new NestedClassMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.GenericParam: return TableInfo.Columns.Count == 5 ? (MetadataTableRecordVM)new GenericParamMetadataTableRecordV11VM(this, new MDToken(TableInfo.Table, index + 1)) : new GenericParamMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MethodSpec: return new MethodSpecMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.GenericParamConstraint: return new GenericParamConstraintMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.Document: return new DocumentMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.MethodDebugInformation: return new MethodDebugInformationMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.LocalScope: return new LocalScopeMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.LocalVariable: return new LocalVariableMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.LocalConstant: return new LocalConstantMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.ImportScope: return new ImportScopeMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.StateMachineMethod: return new StateMachineMethodMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
case Table.CustomDebugInformation: return new CustomDebugInformationMetadataTableRecordVM(this, new MDToken(TableInfo.Table, index + 1));
default: throw new InvalidOperationException();
}
}
public static MetaDataTableVM Create(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan) {
public static MetadataTableVM Create(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan) {
switch (mdTable.Table) {
case Table.Module: return new ModuleMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.TypeRef: return new TypeRefMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.TypeDef: return new TypeDefMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.FieldPtr: return new FieldPtrMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Field: return new FieldMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MethodPtr: return new MethodPtrMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Method: return new MethodMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ParamPtr: return new ParamPtrMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Param: return new ParamMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.InterfaceImpl: return new InterfaceImplMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MemberRef: return new MemberRefMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Constant: return new ConstantMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.CustomAttribute: return new CustomAttributeMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.FieldMarshal: return new FieldMarshalMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.DeclSecurity: return new DeclSecurityMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ClassLayout: return new ClassLayoutMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.FieldLayout: return new FieldLayoutMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.StandAloneSig: return new StandAloneSigMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.EventMap: return new EventMapMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.EventPtr: return new EventPtrMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Event: return new EventMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.PropertyMap: return new PropertyMapMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.PropertyPtr: return new PropertyPtrMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Property: return new PropertyMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MethodSemantics: return new MethodSemanticsMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MethodImpl: return new MethodImplMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ModuleRef: return new ModuleRefMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.TypeSpec: return new TypeSpecMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ImplMap: return new ImplMapMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.FieldRVA: return new FieldRVAMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ENCLog: return new ENCLogMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ENCMap: return new ENCMapMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Assembly: return new AssemblyMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.AssemblyProcessor: return new AssemblyProcessorMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.AssemblyOS: return new AssemblyOSMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.AssemblyRef: return new AssemblyRefMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.AssemblyRefProcessor: return new AssemblyRefProcessorMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.AssemblyRefOS: return new AssemblyRefOSMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.File: return new FileMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ExportedType: return new ExportedTypeMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ManifestResource: return new ManifestResourceMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.NestedClass: return new NestedClassMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.GenericParam: return mdTable.Columns.Count == 5 ? (MetaDataTableVM)new GenericParamMetaDataTableV11VM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) : new GenericParamMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MethodSpec: return new MethodSpecMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.GenericParamConstraint: return new GenericParamConstraintMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Document: return new DocumentMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MethodDebugInformation: return new MethodDebugInformationMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.LocalScope: return new LocalScopeMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.LocalVariable: return new LocalVariableMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.LocalConstant: return new LocalConstantMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ImportScope: return new ImportScopeMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.StateMachineMethod: return new StateMachineMethodMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.CustomDebugInformation: return new CustomDebugInformationMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Module: return new ModuleMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.TypeRef: return new TypeRefMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.TypeDef: return new TypeDefMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.FieldPtr: return new FieldPtrMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Field: return new FieldMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MethodPtr: return new MethodPtrMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Method: return new MethodMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ParamPtr: return new ParamPtrMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Param: return new ParamMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.InterfaceImpl: return new InterfaceImplMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MemberRef: return new MemberRefMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Constant: return new ConstantMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.CustomAttribute: return new CustomAttributeMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.FieldMarshal: return new FieldMarshalMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.DeclSecurity: return new DeclSecurityMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ClassLayout: return new ClassLayoutMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.FieldLayout: return new FieldLayoutMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.StandAloneSig: return new StandAloneSigMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.EventMap: return new EventMapMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.EventPtr: return new EventPtrMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Event: return new EventMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.PropertyMap: return new PropertyMapMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.PropertyPtr: return new PropertyPtrMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Property: return new PropertyMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MethodSemantics: return new MethodSemanticsMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MethodImpl: return new MethodImplMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ModuleRef: return new ModuleRefMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.TypeSpec: return new TypeSpecMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ImplMap: return new ImplMapMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.FieldRVA: return new FieldRVAMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ENCLog: return new ENCLogMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ENCMap: return new ENCMapMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Assembly: return new AssemblyMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.AssemblyProcessor: return new AssemblyProcessorMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.AssemblyOS: return new AssemblyOSMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.AssemblyRef: return new AssemblyRefMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.AssemblyRefProcessor: return new AssemblyRefProcessorMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.AssemblyRefOS: return new AssemblyRefOSMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.File: return new FileMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ExportedType: return new ExportedTypeMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ManifestResource: return new ManifestResourceMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.NestedClass: return new NestedClassMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.GenericParam: return mdTable.Columns.Count == 5 ? (MetadataTableVM)new GenericParamMetadataTableV11VM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) : new GenericParamMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MethodSpec: return new MethodSpecMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.GenericParamConstraint: return new GenericParamConstraintMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.Document: return new DocumentMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.MethodDebugInformation: return new MethodDebugInformationMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.LocalScope: return new LocalScopeMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.LocalVariable: return new LocalVariableMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.LocalConstant: return new LocalConstantMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.ImportScope: return new ImportScopeMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.StateMachineMethod: return new StateMachineMethodMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
case Table.CustomDebugInformation: return new CustomDebugInformationMetadataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
default: throw new InvalidOperationException();
}
}
@ -243,8 +243,8 @@ namespace dnSpy.AsmEditor.Hex.PE {
}
}
public MetaDataTableRecordVM Get(int index) => Collection[index];
public MetaDataTableRecordVM TryGet(int index) => Collection.TryGet(index);
public MetadataTableRecordVM Get(int index) => Collection[index];
public MetadataTableRecordVM TryGet(int index) => Collection.TryGet(index);
public string ReadStringsHeap(uint offset, uint maxLen = 0x200) {
if (offset == 0)
@ -286,424 +286,424 @@ namespace dnSpy.AsmEditor.Hex.PE {
}
}
abstract class MetaDataTable1VM : MetaDataTableVM {
public MetaDataTable1VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
abstract class MetadataTable1VM : MetadataTableVM {
public MetadataTable1VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable2VM : MetaDataTableVM {
public MetaDataTable2VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
abstract class MetadataTable2VM : MetadataTableVM {
public MetadataTable2VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable3VM : MetaDataTableVM {
public MetaDataTable3VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
abstract class MetadataTable3VM : MetadataTableVM {
public MetadataTable3VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable4VM : MetaDataTableVM {
public MetaDataTable4VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
abstract class MetadataTable4VM : MetadataTableVM {
public MetadataTable4VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable5VM : MetaDataTableVM {
public MetaDataTable5VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
abstract class MetadataTable5VM : MetadataTableVM {
public MetadataTable5VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable6VM : MetaDataTableVM {
public MetaDataTable6VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
abstract class MetadataTable6VM : MetadataTableVM {
public MetadataTable6VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable9VM : MetaDataTableVM {
public MetaDataTable9VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
abstract class MetadataTable9VM : MetadataTableVM {
public MetadataTable9VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable1InfoVM : MetaDataTable1VM {
abstract class MetadataTable1InfoVM : MetadataTable1VM {
public override bool HasInfo => true;
public MetaDataTable1InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
public MetadataTable1InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable2InfoVM : MetaDataTable2VM {
abstract class MetadataTable2InfoVM : MetadataTable2VM {
public override bool HasInfo => true;
public MetaDataTable2InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
public MetadataTable2InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable3InfoVM : MetaDataTable3VM {
abstract class MetadataTable3InfoVM : MetadataTable3VM {
public override bool HasInfo => true;
public MetaDataTable3InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
public MetadataTable3InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable4InfoVM : MetaDataTable4VM {
abstract class MetadataTable4InfoVM : MetadataTable4VM {
public override bool HasInfo => true;
public MetaDataTable4InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
public MetadataTable4InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable5InfoVM : MetaDataTable5VM {
abstract class MetadataTable5InfoVM : MetadataTable5VM {
public override bool HasInfo => true;
public MetaDataTable5InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
public MetadataTable5InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable6InfoVM : MetaDataTable6VM {
abstract class MetadataTable6InfoVM : MetadataTable6VM {
public override bool HasInfo => true;
public MetaDataTable6InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
public MetadataTable6InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
abstract class MetaDataTable9InfoVM : MetaDataTable9VM {
abstract class MetadataTable9InfoVM : MetadataTable9VM {
public override bool HasInfo => true;
public MetaDataTable9InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
public MetadataTable9InfoVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ModuleMetaDataTableVM : MetaDataTable5InfoVM {
public ModuleMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ModuleMetadataTableVM : MetadataTable5InfoVM {
public ModuleMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class TypeRefMetaDataTableVM : MetaDataTable3InfoVM {
public TypeRefMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class TypeRefMetadataTableVM : MetadataTable3InfoVM {
public TypeRefMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class TypeDefMetaDataTableVM : MetaDataTable6InfoVM {
public TypeDefMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class TypeDefMetadataTableVM : MetadataTable6InfoVM {
public TypeDefMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class FieldPtrMetaDataTableVM : MetaDataTable1VM {
public FieldPtrMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class FieldPtrMetadataTableVM : MetadataTable1VM {
public FieldPtrMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class FieldMetaDataTableVM : MetaDataTable3InfoVM {
public FieldMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class FieldMetadataTableVM : MetadataTable3InfoVM {
public FieldMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class MethodPtrMetaDataTableVM : MetaDataTable1VM {
public MethodPtrMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class MethodPtrMetadataTableVM : MetadataTable1VM {
public MethodPtrMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class MethodMetaDataTableVM : MetaDataTable6InfoVM {
public MethodMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class MethodMetadataTableVM : MetadataTable6InfoVM {
public MethodMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ParamPtrMetaDataTableVM : MetaDataTable1VM {
public ParamPtrMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ParamPtrMetadataTableVM : MetadataTable1VM {
public ParamPtrMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ParamMetaDataTableVM : MetaDataTable3InfoVM {
public ParamMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ParamMetadataTableVM : MetadataTable3InfoVM {
public ParamMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class InterfaceImplMetaDataTableVM : MetaDataTable2VM {
public InterfaceImplMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class InterfaceImplMetadataTableVM : MetadataTable2VM {
public InterfaceImplMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class MemberRefMetaDataTableVM : MetaDataTable3InfoVM {
public MemberRefMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class MemberRefMetadataTableVM : MetadataTable3InfoVM {
public MemberRefMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ConstantMetaDataTableVM : MetaDataTable4VM {
public ConstantMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ConstantMetadataTableVM : MetadataTable4VM {
public ConstantMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class CustomAttributeMetaDataTableVM : MetaDataTable3VM {
public CustomAttributeMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class CustomAttributeMetadataTableVM : MetadataTable3VM {
public CustomAttributeMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class FieldMarshalMetaDataTableVM : MetaDataTable2VM {
public FieldMarshalMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class FieldMarshalMetadataTableVM : MetadataTable2VM {
public FieldMarshalMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class DeclSecurityMetaDataTableVM : MetaDataTable3VM {
public DeclSecurityMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class DeclSecurityMetadataTableVM : MetadataTable3VM {
public DeclSecurityMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ClassLayoutMetaDataTableVM : MetaDataTable3VM {
public ClassLayoutMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ClassLayoutMetadataTableVM : MetadataTable3VM {
public ClassLayoutMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class FieldLayoutMetaDataTableVM : MetaDataTable2VM {
public FieldLayoutMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class FieldLayoutMetadataTableVM : MetadataTable2VM {
public FieldLayoutMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class StandAloneSigMetaDataTableVM : MetaDataTable1VM {
public StandAloneSigMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class StandAloneSigMetadataTableVM : MetadataTable1VM {
public StandAloneSigMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class EventMapMetaDataTableVM : MetaDataTable2VM {
public EventMapMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class EventMapMetadataTableVM : MetadataTable2VM {
public EventMapMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class EventPtrMetaDataTableVM : MetaDataTable1VM {
public EventPtrMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class EventPtrMetadataTableVM : MetadataTable1VM {
public EventPtrMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class EventMetaDataTableVM : MetaDataTable3InfoVM {
public EventMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class EventMetadataTableVM : MetadataTable3InfoVM {
public EventMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class PropertyMapMetaDataTableVM : MetaDataTable2VM {
public PropertyMapMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class PropertyMapMetadataTableVM : MetadataTable2VM {
public PropertyMapMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class PropertyPtrMetaDataTableVM : MetaDataTable1VM {
public PropertyPtrMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class PropertyPtrMetadataTableVM : MetadataTable1VM {
public PropertyPtrMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class PropertyMetaDataTableVM : MetaDataTable3InfoVM {
public PropertyMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class PropertyMetadataTableVM : MetadataTable3InfoVM {
public PropertyMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class MethodSemanticsMetaDataTableVM : MetaDataTable3VM {
public MethodSemanticsMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class MethodSemanticsMetadataTableVM : MetadataTable3VM {
public MethodSemanticsMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class MethodImplMetaDataTableVM : MetaDataTable3VM {
public MethodImplMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class MethodImplMetadataTableVM : MetadataTable3VM {
public MethodImplMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ModuleRefMetaDataTableVM : MetaDataTable1InfoVM {
public ModuleRefMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ModuleRefMetadataTableVM : MetadataTable1InfoVM {
public ModuleRefMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class TypeSpecMetaDataTableVM : MetaDataTable1VM {
public TypeSpecMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class TypeSpecMetadataTableVM : MetadataTable1VM {
public TypeSpecMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ImplMapMetaDataTableVM : MetaDataTable4InfoVM {
public ImplMapMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ImplMapMetadataTableVM : MetadataTable4InfoVM {
public ImplMapMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class FieldRVAMetaDataTableVM : MetaDataTable2VM {
public FieldRVAMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class FieldRVAMetadataTableVM : MetadataTable2VM {
public FieldRVAMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ENCLogMetaDataTableVM : MetaDataTable2VM {
public ENCLogMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ENCLogMetadataTableVM : MetadataTable2VM {
public ENCLogMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ENCMapMetaDataTableVM : MetaDataTable1VM {
public ENCMapMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ENCMapMetadataTableVM : MetadataTable1VM {
public ENCMapMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class AssemblyMetaDataTableVM : MetaDataTable9InfoVM {
public AssemblyMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class AssemblyMetadataTableVM : MetadataTable9InfoVM {
public AssemblyMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class AssemblyProcessorMetaDataTableVM : MetaDataTable1VM {
public AssemblyProcessorMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class AssemblyProcessorMetadataTableVM : MetadataTable1VM {
public AssemblyProcessorMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class AssemblyOSMetaDataTableVM : MetaDataTable3VM {
public AssemblyOSMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class AssemblyOSMetadataTableVM : MetadataTable3VM {
public AssemblyOSMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class AssemblyRefMetaDataTableVM : MetaDataTable9InfoVM {
public AssemblyRefMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class AssemblyRefMetadataTableVM : MetadataTable9InfoVM {
public AssemblyRefMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class AssemblyRefProcessorMetaDataTableVM : MetaDataTable2VM {
public AssemblyRefProcessorMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class AssemblyRefProcessorMetadataTableVM : MetadataTable2VM {
public AssemblyRefProcessorMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class AssemblyRefOSMetaDataTableVM : MetaDataTable4VM {
public AssemblyRefOSMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class AssemblyRefOSMetadataTableVM : MetadataTable4VM {
public AssemblyRefOSMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class FileMetaDataTableVM : MetaDataTable3InfoVM {
public FileMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class FileMetadataTableVM : MetadataTable3InfoVM {
public FileMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ExportedTypeMetaDataTableVM : MetaDataTable5InfoVM {
public ExportedTypeMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ExportedTypeMetadataTableVM : MetadataTable5InfoVM {
public ExportedTypeMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ManifestResourceMetaDataTableVM : MetaDataTable4InfoVM {
public ManifestResourceMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ManifestResourceMetadataTableVM : MetadataTable4InfoVM {
public ManifestResourceMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class NestedClassMetaDataTableVM : MetaDataTable2VM {
public NestedClassMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class NestedClassMetadataTableVM : MetadataTable2VM {
public NestedClassMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class GenericParamMetaDataTableV11VM : MetaDataTable5InfoVM {
public GenericParamMetaDataTableV11VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class GenericParamMetadataTableV11VM : MetadataTable5InfoVM {
public GenericParamMetadataTableV11VM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class GenericParamMetaDataTableVM : MetaDataTable4InfoVM {
public GenericParamMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class GenericParamMetadataTableVM : MetadataTable4InfoVM {
public GenericParamMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class MethodSpecMetaDataTableVM : MetaDataTable2VM {
public MethodSpecMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class MethodSpecMetadataTableVM : MetadataTable2VM {
public MethodSpecMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class GenericParamConstraintMetaDataTableVM : MetaDataTable2VM {
public GenericParamConstraintMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class GenericParamConstraintMetadataTableVM : MetadataTable2VM {
public GenericParamConstraintMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class DocumentMetaDataTableVM : MetaDataTable4VM {
public DocumentMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class DocumentMetadataTableVM : MetadataTable4VM {
public DocumentMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class MethodDebugInformationMetaDataTableVM : MetaDataTable2VM {
public MethodDebugInformationMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class MethodDebugInformationMetadataTableVM : MetadataTable2VM {
public MethodDebugInformationMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class LocalScopeMetaDataTableVM : MetaDataTable6VM {
public LocalScopeMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class LocalScopeMetadataTableVM : MetadataTable6VM {
public LocalScopeMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class LocalVariableMetaDataTableVM : MetaDataTable3VM {
public LocalVariableMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class LocalVariableMetadataTableVM : MetadataTable3VM {
public LocalVariableMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class LocalConstantMetaDataTableVM : MetaDataTable2VM {
public LocalConstantMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class LocalConstantMetadataTableVM : MetadataTable2VM {
public LocalConstantMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class ImportScopeMetaDataTableVM : MetaDataTable2VM {
public ImportScopeMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class ImportScopeMetadataTableVM : MetadataTable2VM {
public ImportScopeMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class StateMachineMethodMetaDataTableVM : MetaDataTable2VM {
public StateMachineMethodMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class StateMachineMethodMetadataTableVM : MetadataTable2VM {
public StateMachineMethodMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}
sealed class CustomDebugInformationMetaDataTableVM : MetaDataTable3VM {
public CustomDebugInformationMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
sealed class CustomDebugInformationMetadataTableVM : MetadataTable3VM {
public CustomDebugInformationMetadataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
: base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) {
}
}

View File

@ -123,14 +123,14 @@ namespace dnSpy.AsmEditor.Hex.PE {
storageStreams[i] = new StorageStreamVM(buffer, heap, ssh, i);
}
var metaDataTables = new MetaDataTableVM[0x40];
var metadataTables = new MetadataTableVM[0x40];
if (mdHeaders.TablesStream != null) {
tablesStream = new TablesStreamVM(buffer, mdHeaders.TablesStream, metaDataTables);
tablesStream = new TablesStreamVM(buffer, mdHeaders.TablesStream, metadataTables);
var stringsHeapSpan = GetSpan(mdHeaders.StringsStream);
var guidHeapSpan = GetSpan(mdHeaders.GUIDStream);
foreach (var mdTable in mdHeaders.TablesStream.MDTables) {
if (mdTable.Rows != 0)
metaDataTables[(int)mdTable.Table] = MetaDataTableVM.Create(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
metadataTables[(int)mdTable.Table] = MetadataTableVM.Create(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
}
}
}

View File

@ -105,13 +105,13 @@ namespace dnSpy.AsmEditor.Hex.PE {
public override IEnumerable<HexField> HexFields => hexFields;
readonly HexField[] hexFields;
public MetaDataTableVM[] MetaDataTables => metaDataTables;
readonly MetaDataTableVM[] metaDataTables;
public MetadataTableVM[] MetadataTables => metadataTables;
readonly MetadataTableVM[] metadataTables;
public TablesStreamVM(HexBuffer buffer, TablesHeap tablesHeap, MetaDataTableVM[] metaDataTables)
public TablesStreamVM(HexBuffer buffer, TablesHeap tablesHeap, MetadataTableVM[] metadataTables)
: base(tablesHeap.HeaderSpan) {
Debug.Assert(metaDataTables.Length == 0x40);
this.metaDataTables = metaDataTables;
Debug.Assert(metadataTables.Length == 0x40);
this.metadataTables = metadataTables;
Name = tablesHeap.Header.Name;
M_ulReservedVM = new UInt32HexField(tablesHeap.Header.Reserved);
M_majorVM = new ByteHexField(tablesHeap.Header.MajorVersion, true);
@ -232,10 +232,10 @@ namespace dnSpy.AsmEditor.Hex.PE {
field.Add(new BooleanHexBitField("Reserved 3F", 63));
}
public MetaDataTableVM TryGetMetaDataTable(Table table) {
if ((uint)table >= (uint)metaDataTables.Length)
public MetadataTableVM TryGetMetadataTable(Table table) {
if ((uint)table >= (uint)metadataTables.Length)
return null;
return metaDataTables[(int)table];
return metadataTables[(int)table];
}
}
}

View File

@ -133,8 +133,8 @@ namespace dnSpy.AsmEditor.Module {
}
public bool Bit32Machine {
get => GetFlagValue(dnlib.PE.Characteristics._32BitMachine);
set => SetFlagValue(dnlib.PE.Characteristics._32BitMachine, value);
get => GetFlagValue(dnlib.PE.Characteristics.Bit32Machine);
set => SetFlagValue(dnlib.PE.Characteristics.Bit32Machine, value);
}
public bool DebugStripped {
@ -330,8 +330,8 @@ namespace dnSpy.AsmEditor.Module {
}
public bool Bit32Required {
get => GetFlagValue(ComImageFlags._32BitRequired);
set => SetFlagValue(ComImageFlags._32BitRequired, value);
get => GetFlagValue(ComImageFlags.Bit32Required);
set => SetFlagValue(ComImageFlags.Bit32Required, value);
}
public bool ILLibrary {
@ -350,8 +350,8 @@ namespace dnSpy.AsmEditor.Module {
}
public bool Bit32Preferred {
get => GetFlagValue(ComImageFlags._32BitPreferred);
set => SetFlagValue(ComImageFlags._32BitPreferred, value);
get => GetFlagValue(ComImageFlags.Bit32Preferred);
set => SetFlagValue(ComImageFlags.Bit32Preferred, value);
}
bool GetFlagValue(ComImageFlags flag) => (Cor20HeaderFlags & flag) != 0;
@ -550,7 +550,7 @@ namespace dnSpy.AsmEditor.Module {
protected override string Verify(string columnName) {
if (columnName == nameof(RuntimeVersion))
return SaveModule.MetaDataHeaderOptionsVM.ValidateVersionString(options.RuntimeVersion);
return SaveModule.MetadataHeaderOptionsVM.ValidateVersionString(options.RuntimeVersion);
return string.Empty;
}

View File

@ -28,7 +28,7 @@ namespace dnSpy.AsmEditor.Module {
public static ModuleDef CreateModule(string name, Guid mvid, ClrVersion clrVersion, ModuleKind kind, ModuleDef existingModule = null) {
var module = CreateModuleDef(name, mvid, clrVersion, existingModule);
module.Kind = kind;
module.Characteristics = Characteristics._32BitMachine | Characteristics.ExecutableImage;
module.Characteristics = Characteristics.Bit32Machine | Characteristics.ExecutableImage;
if (kind == ModuleKind.Dll || kind == ModuleKind.NetModule)
module.Characteristics |= Characteristics.Dll;
module.DllCharacteristics = DllCharacteristics.TerminalServerAware | DllCharacteristics.NoSeh | DllCharacteristics.NxCompat | DllCharacteristics.DynamicBase;

View File

@ -948,7 +948,7 @@ namespace dnSpy.AsmEditor.Resources {
ResourceType = ResourceType.Linked,
Name = "filelinked",
Attributes = ManifestResourceAttributes.Public,
File = new FileDefUser("somefile", dnlib.DotNet.FileAttributes.ContainsNoMetaData, Array.Empty<byte>()),
File = new FileDefUser("somefile", dnlib.DotNet.FileAttributes.ContainsNoMetadata, Array.Empty<byte>()),
};
var data = new ResourceVM(options, module);
var win = new ResourceDlg();

View File

@ -49,6 +49,6 @@
<TextBox Grid.Row="3" Grid.Column="1" Margin="5 5 0 0" Name="fileNameTextBox" Text="{Binding FileName, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding IsLinked, Converter={StaticResource BooleanToVisibilityConverter}}" />
<Label Grid.Row="4" Grid.Column="0" Margin="0 5 0 0" Target="{Binding ElementName=fileHashValueTextBox}" Content="{x:Static p:dnSpy_AsmEditor_Resources.EditResource_Hash}" Visibility="{Binding IsLinked, Converter={StaticResource BooleanToVisibilityConverter}}" />
<TextBox Grid.Row="4" Grid.Column="1" Margin="5 5 0 0" Name="fileHashValueTextBox" Text="{Binding FileHashValue.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding IsLinked, Converter={StaticResource BooleanToVisibilityConverter}}" />
<CheckBox Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" Margin="5 5 0 0" IsChecked="{Binding FileContainsNoMetaData}" Content="{x:Static p:dnSpy_AsmEditor_Resources.EditResource_ContainsNoMetadata}" Visibility="{Binding IsLinked, Converter={StaticResource BooleanToVisibilityConverter}}" />
<CheckBox Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" Margin="5 5 0 0" IsChecked="{Binding FileContainsNoMetadata}" Content="{x:Static p:dnSpy_AsmEditor_Resources.EditResource_ContainsNoMetadata}" Visibility="{Binding IsLinked, Converter={StaticResource BooleanToVisibilityConverter}}" />
</Grid>
</UserControl>

View File

@ -118,16 +118,16 @@ namespace dnSpy.AsmEditor.Resources {
}
UTF8String fileName;
public bool FileContainsNoMetaData {
get => fileContainsNoMetaData;
public bool FileContainsNoMetadata {
get => fileContainsNoMetadata;
set {
if (fileContainsNoMetaData != value) {
fileContainsNoMetaData = value;
OnPropertyChanged(nameof(FileContainsNoMetaData));
if (fileContainsNoMetadata != value) {
fileContainsNoMetadata = value;
OnPropertyChanged(nameof(FileContainsNoMetadata));
}
}
}
bool fileContainsNoMetaData;
bool fileContainsNoMetadata;
readonly ModuleDef ownerModule;
@ -160,12 +160,12 @@ namespace dnSpy.AsmEditor.Resources {
if (options.File != null) {
FileHashValue.Value = options.File.HashValue;
FileName = options.File.Name ?? UTF8String.Empty;
FileContainsNoMetaData = options.File.ContainsNoMetaData;
FileContainsNoMetadata = options.File.ContainsNoMetadata;
}
else {
FileHashValue.Value = Array.Empty<byte>();
FileName = string.Empty;
FileContainsNoMetaData = false;
FileContainsNoMetadata = false;
}
}
@ -175,7 +175,7 @@ namespace dnSpy.AsmEditor.Resources {
options.Name = Name;
options.Assembly = Assembly;
options.File = new FileDefUser(FileName,
FileContainsNoMetaData ? FileAttributes.ContainsNoMetaData : FileAttributes.ContainsMetaData,
FileContainsNoMetadata ? FileAttributes.ContainsNoMetadata : FileAttributes.ContainsMetadata,
FileHashValue.Value.ToArray());
return options;
}

View File

@ -32,11 +32,11 @@ namespace dnSpy.AsmEditor.SaveModule {
public static Characteristics GetCharacteristics(Characteristics characteristics, Machine machine) {
if (machine == Machine.IA64 || machine == Machine.AMD64 || machine == Machine.ARM64) {
characteristics &= ~Characteristics._32BitMachine;
characteristics &= ~Characteristics.Bit32Machine;
characteristics |= Characteristics.LargeAddressAware;
}
else
characteristics |= Characteristics._32BitMachine;
characteristics |= Characteristics.Bit32Machine;
return characteristics;
}
}

View File

@ -226,7 +226,7 @@ namespace dnSpy.AsmEditor.SaveModule {
opts.WriterEvent += OnWriterEvent;
opts.Logger = this;
// Make sure the order of the interfaces don't change, see https://github.com/dotnet/roslyn/issues/3905
opts.MetaDataOptions.Flags |= MetaDataFlags.RoslynSortInterfaceImpl;
opts.MetadataOptions.Flags |= MetadataFlags.RoslynSortInterfaceImpl;
var filename = vm.FileName;
if (opts is NativeModuleWriterOptions)
((ModuleDefMD)vm.Module).NativeWrite(filename, (NativeModuleWriterOptions)opts);

View File

@ -83,7 +83,7 @@
<StackPanel>
<GroupBox ToolTip="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_PreserveTokens_ToolTip}" IsEnabled="{Binding CanSaveMixedModeModule}">
<GroupBox.Header>
<CheckBox IsThreeState="False" IsChecked="{Binding MetaDataOptions.PreserveRids}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_PreserveTokens}" />
<CheckBox IsThreeState="False" IsChecked="{Binding MetadataOptions.PreserveRids}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_PreserveTokens}" />
</GroupBox.Header>
<Grid>
<Grid.RowDefinitions>
@ -98,17 +98,17 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<CheckBox Grid.Row="0" Grid.Column="0" Margin="0 0 0 0" Content="_TypeRef" IsChecked="{Binding MetaDataOptions.PreserveTypeRefRids}" />
<CheckBox Grid.Row="0" Grid.Column="1" Margin="5 0 0 0" Content="T_ypeDef" IsChecked="{Binding MetaDataOptions.PreserveTypeDefRids}" />
<CheckBox Grid.Row="1" Grid.Column="0" Margin="0 5 0 0" Content="_Field" IsChecked="{Binding MetaDataOptions.PreserveFieldRids}" />
<CheckBox Grid.Row="1" Grid.Column="1" Margin="5 5 0 0" Content="Met_hod" IsChecked="{Binding MetaDataOptions.PreserveMethodRids}" />
<CheckBox Grid.Row="2" Grid.Column="0" Margin="0 5 0 0" Content="P_aram" IsChecked="{Binding MetaDataOptions.PreserveParamRids}" />
<CheckBox Grid.Row="2" Grid.Column="1" Margin="5 5 0 0" Content="_MemberRef" IsChecked="{Binding MetaDataOptions.PreserveMemberRefRids}" />
<CheckBox Grid.Row="3" Grid.Column="0" Margin="0 5 0 0" Content="StandAloneS_ig" IsChecked="{Binding MetaDataOptions.PreserveStandAloneSigRids}" />
<CheckBox Grid.Row="3" Grid.Column="1" Margin="5 5 0 0" Content="E_vent" IsChecked="{Binding MetaDataOptions.PreserveEventRids}" />
<CheckBox Grid.Row="4" Grid.Column="0" Margin="0 5 0 0" Content="Prop_erty" IsChecked="{Binding MetaDataOptions.PreservePropertyRids}" />
<CheckBox Grid.Row="4" Grid.Column="1" Margin="5 5 0 0" Content="Ty_peSpec" IsChecked="{Binding MetaDataOptions.PreserveTypeSpecRids}" />
<CheckBox Grid.Row="5" Grid.Column="0" Margin="0 5 0 0" Content="Metho_dSpec" IsChecked="{Binding MetaDataOptions.PreserveMethodSpecRids}" />
<CheckBox Grid.Row="0" Grid.Column="0" Margin="0 0 0 0" Content="_TypeRef" IsChecked="{Binding MetadataOptions.PreserveTypeRefRids}" />
<CheckBox Grid.Row="0" Grid.Column="1" Margin="5 0 0 0" Content="T_ypeDef" IsChecked="{Binding MetadataOptions.PreserveTypeDefRids}" />
<CheckBox Grid.Row="1" Grid.Column="0" Margin="0 5 0 0" Content="_Field" IsChecked="{Binding MetadataOptions.PreserveFieldRids}" />
<CheckBox Grid.Row="1" Grid.Column="1" Margin="5 5 0 0" Content="Met_hod" IsChecked="{Binding MetadataOptions.PreserveMethodRids}" />
<CheckBox Grid.Row="2" Grid.Column="0" Margin="0 5 0 0" Content="P_aram" IsChecked="{Binding MetadataOptions.PreserveParamRids}" />
<CheckBox Grid.Row="2" Grid.Column="1" Margin="5 5 0 0" Content="_MemberRef" IsChecked="{Binding MetadataOptions.PreserveMemberRefRids}" />
<CheckBox Grid.Row="3" Grid.Column="0" Margin="0 5 0 0" Content="StandAloneS_ig" IsChecked="{Binding MetadataOptions.PreserveStandAloneSigRids}" />
<CheckBox Grid.Row="3" Grid.Column="1" Margin="5 5 0 0" Content="E_vent" IsChecked="{Binding MetadataOptions.PreserveEventRids}" />
<CheckBox Grid.Row="4" Grid.Column="0" Margin="0 5 0 0" Content="Prop_erty" IsChecked="{Binding MetadataOptions.PreservePropertyRids}" />
<CheckBox Grid.Row="4" Grid.Column="1" Margin="5 5 0 0" Content="Ty_peSpec" IsChecked="{Binding MetadataOptions.PreserveTypeSpecRids}" />
<CheckBox Grid.Row="5" Grid.Column="0" Margin="0 5 0 0" Content="Metho_dSpec" IsChecked="{Binding MetadataOptions.PreserveMethodSpecRids}" />
</Grid>
</GroupBox>
<GroupBox Header="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_PreserveHeapOffsets}" IsEnabled="{Binding CanSaveMixedModeModule}" Margin="0 5 0 0" >
@ -122,9 +122,9 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<CheckBox Grid.Row="0" Grid.Column="0" Margin="0 0 0 0" Content="#Stri_ngs" IsChecked="{Binding MetaDataOptions.PreserveStringsOffsets}" />
<CheckBox Grid.Row="0" Grid.Column="1" Margin="5 0 0 0" Content="#_US" IsChecked="{Binding MetaDataOptions.PreserveUSOffsets}" />
<CheckBox Grid.Row="0" Grid.Column="2" Margin="5 0 0 0" Content="#_Blob" IsChecked="{Binding MetaDataOptions.PreserveBlobOffsets}" />
<CheckBox Grid.Row="0" Grid.Column="0" Margin="0 0 0 0" Content="#Stri_ngs" IsChecked="{Binding MetadataOptions.PreserveStringsOffsets}" />
<CheckBox Grid.Row="0" Grid.Column="1" Margin="5 0 0 0" Content="#_US" IsChecked="{Binding MetadataOptions.PreserveUSOffsets}" />
<CheckBox Grid.Row="0" Grid.Column="2" Margin="5 0 0 0" Content="#_Blob" IsChecked="{Binding MetadataOptions.PreserveBlobOffsets}" />
</Grid>
</GroupBox>
<GroupBox Header="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_CreateHeapEvenIfEmpty}" Margin="0 5 0 0" >
@ -139,10 +139,10 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<CheckBox Grid.Row="0" Grid.Column="0" Margin="0 0 0 0" Content="#Strings" IsChecked="{Binding MetaDataOptions.AlwaysCreateStringsHeap}" />
<CheckBox Grid.Row="0" Grid.Column="1" Margin="5 0 0 0" Content="#U_S" IsChecked="{Binding MetaDataOptions.AlwaysCreateUSHeap}" />
<CheckBox Grid.Row="0" Grid.Column="2" Margin="5 0 0 0" Content="#B_lob" IsChecked="{Binding MetaDataOptions.AlwaysCreateBlobHeap}" />
<CheckBox Grid.Row="0" Grid.Column="3" Margin="5 0 0 0" Content="#_Guid" IsChecked="{Binding MetaDataOptions.AlwaysCreateGuidHeap}" />
<CheckBox Grid.Row="0" Grid.Column="0" Margin="0 0 0 0" Content="#Strings" IsChecked="{Binding MetadataOptions.AlwaysCreateStringsHeap}" />
<CheckBox Grid.Row="0" Grid.Column="1" Margin="5 0 0 0" Content="#U_S" IsChecked="{Binding MetadataOptions.AlwaysCreateUSHeap}" />
<CheckBox Grid.Row="0" Grid.Column="2" Margin="5 0 0 0" Content="#B_lob" IsChecked="{Binding MetadataOptions.AlwaysCreateBlobHeap}" />
<CheckBox Grid.Row="0" Grid.Column="3" Margin="5 0 0 0" Content="#_Guid" IsChecked="{Binding MetadataOptions.AlwaysCreateGuidHeap}" />
</Grid>
</GroupBox>
<GroupBox Header="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_MiscOptions}" Margin="0 5 0 0">
@ -154,8 +154,8 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<CheckBox Grid.Column="0" Margin="0 0 0 0" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_PreserveExtraSigData}" IsChecked="{Binding MetaDataOptions.PreserveExtraSignatureData}" ToolTip="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_PreserveExtraSigData_ToolTip}" IsEnabled="{Binding CanSaveMixedModeModule}" />
<CheckBox Grid.Column="1" Margin="5 0 0 0" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_KeepOldMaxStack}" IsChecked="{Binding MetaDataOptions.KeepOldMaxStack}" ToolTip="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_KeepOldMaxStack_ToolTip}" />
<CheckBox Grid.Column="0" Margin="0 0 0 0" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_PreserveExtraSigData}" IsChecked="{Binding MetadataOptions.PreserveExtraSignatureData}" ToolTip="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_PreserveExtraSigData_ToolTip}" IsEnabled="{Binding CanSaveMixedModeModule}" />
<CheckBox Grid.Column="1" Margin="5 0 0 0" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_KeepOldMaxStack}" IsChecked="{Binding MetadataOptions.KeepOldMaxStack}" ToolTip="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_KeepOldMaxStack_ToolTip}" />
</Grid>
</GroupBox>
</StackPanel>
@ -180,19 +180,19 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Margin="0 0 0 0" Target="{Binding ElementName=signatureTextBox}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_Metadata_Signature}" />
<TextBox Grid.Row="0" Grid.Column="1" Margin="5 0 0 0" Name="signatureTextBox" Text="{Binding MetaDataOptions.MetaDataHeaderOptions.Signature.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.Row="0" Grid.Column="1" Margin="5 0 0 0" Name="signatureTextBox" Text="{Binding MetadataOptions.MetadataHeaderOptions.Signature.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="0" Grid.Column="2" Margin="5 0 0 0" Target="{Binding ElementName=versionStringTextBox}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_Metadata_VersionString}" />
<TextBox Grid.Row="0" Grid.Column="3" Margin="5 0 0 0" Name="versionStringTextBox" Text="{Binding MetaDataOptions.MetaDataHeaderOptions.VersionString, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.Row="0" Grid.Column="3" Margin="5 0 0 0" Name="versionStringTextBox" Text="{Binding MetadataOptions.MetadataHeaderOptions.VersionString, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="1" Grid.Column="0" Margin="0 5 0 0" Target="{Binding ElementName=majorVersionTextBox}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_Metadata_MajorVersion}" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="5 5 0 0" Name="majorVersionTextBox" Text="{Binding MetaDataOptions.MetaDataHeaderOptions.MajorVersion.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="5 5 0 0" Name="majorVersionTextBox" Text="{Binding MetadataOptions.MetadataHeaderOptions.MajorVersion.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="1" Grid.Column="2" Margin="5 5 0 0" Target="{Binding ElementName=minorVersionTextBox}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_Metadata_MinorVersion}" />
<TextBox Grid.Row="1" Grid.Column="3" Margin="5 5 0 0" Name="minorVersionTextBox" Text="{Binding MetaDataOptions.MetaDataHeaderOptions.MinorVersion.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.Row="1" Grid.Column="3" Margin="5 5 0 0" Name="minorVersionTextBox" Text="{Binding MetadataOptions.MetadataHeaderOptions.MinorVersion.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="2" Grid.Column="0" Margin="0 5 0 0" Target="{Binding ElementName=reserved1TextBox}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_Metadata_Reserved1}" />
<TextBox Grid.Row="2" Grid.Column="1" Margin="5 5 0 0" Name="reserved1TextBox" Text="{Binding MetaDataOptions.MetaDataHeaderOptions.Reserved1.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.Row="2" Grid.Column="1" Margin="5 5 0 0" Name="reserved1TextBox" Text="{Binding MetadataOptions.MetadataHeaderOptions.Reserved1.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="2" Grid.Column="2" Margin="5 5 0 0" Target="{Binding ElementName=reserved2TextBox}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_Metadata_Reserved2}" />
<TextBox Grid.Row="2" Grid.Column="3" Margin="5 5 0 0" Name="reserved2TextBox" Text="{Binding MetaDataOptions.MetaDataHeaderOptions.Reserved2.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.Row="2" Grid.Column="3" Margin="5 5 0 0" Name="reserved2TextBox" Text="{Binding MetadataOptions.MetadataHeaderOptions.Reserved2.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="3" Grid.Column="0" Margin="0 5 0 0" Target="{Binding ElementName=storageFlagsTextBox}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_Metadata_StorageFlags}" />
<TextBox Grid.Row="3" Grid.Column="1" Margin="5 5 0 0" Name="storageFlagsTextBox" Text="{Binding MetaDataOptions.MetaDataHeaderOptions.StorageFlags.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" ToolTip="Leave this blank or set it only to 0.&#x0A;Any other value will crash the assembly" />
<TextBox Grid.Row="3" Grid.Column="1" Margin="5 5 0 0" Name="storageFlagsTextBox" Text="{Binding MetadataOptions.MetadataHeaderOptions.StorageFlags.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" ToolTip="Leave this blank or set it only to 0.&#x0A;Any other value will crash the assembly" />
</Grid>
</GroupBox>
<GroupBox Header="{x:Static p:dnSpy_AsmEditor_Resources.TablesHeapOptionsTab}" Margin="0 5 0 0">
@ -212,15 +212,15 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Margin="0 0 0 0" Target="{Binding ElementName=majorVersionTextBox2}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_TablesHeap_MajorVersion}" />
<TextBox Grid.Row="0" Grid.Column="1" Margin="5 0 0 0" Name="majorVersionTextBox2" Text="{Binding MetaDataOptions.TablesHeapOptions.MajorVersion.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.Row="0" Grid.Column="1" Margin="5 0 0 0" Name="majorVersionTextBox2" Text="{Binding MetadataOptions.TablesHeapOptions.MajorVersion.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="0" Grid.Column="2" Margin="5 0 0 0" Target="{Binding ElementName=minorVersionTextBox2}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_TablesHeap_MinorVersion}" />
<TextBox Grid.Row="0" Grid.Column="3" Margin="5 0 0 0" Name="minorVersionTextBox2" Text="{Binding MetaDataOptions.TablesHeapOptions.MinorVersion.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.Row="0" Grid.Column="3" Margin="5 0 0 0" Name="minorVersionTextBox2" Text="{Binding MetadataOptions.TablesHeapOptions.MinorVersion.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="1" Grid.Column="0" Margin="0 5 0 0" Target="{Binding ElementName=reserved1TextBox2}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_TablesHeap_Reserved1}" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="5 5 0 0" Name="reserved1TextBox2" Text="{Binding MetaDataOptions.TablesHeapOptions.Reserved1.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="5 5 0 0" Name="reserved1TextBox2" Text="{Binding MetadataOptions.TablesHeapOptions.Reserved1.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="1" Grid.Column="2" Margin="5 5 0 0" Target="{Binding ElementName=extraDataTextBox}" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_TablesHeap_ExtraData}" />
<TextBox Grid.Row="1" Grid.Column="3" Margin="5 5 0 0" Name="extraDataTextBox" Text="{Binding MetaDataOptions.TablesHeapOptions.ExtraData.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="0 5 0 0" IsThreeState="True" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_TablesHeap_HasDeletedRows}" IsChecked="{Binding MetaDataOptions.TablesHeapOptions.HasDeletedRows}" />
<CheckBox Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="5 5 0 0" IsThreeState="True" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_TablesHeap_UseENC}" IsChecked="{Binding MetaDataOptions.TablesHeapOptions.UseENC}" />
<TextBox Grid.Row="1" Grid.Column="3" Margin="5 5 0 0" Name="extraDataTextBox" Text="{Binding MetadataOptions.TablesHeapOptions.ExtraData.StringValue, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="0 5 0 0" IsThreeState="True" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_TablesHeap_HasDeletedRows}" IsChecked="{Binding MetadataOptions.TablesHeapOptions.HasDeletedRows}" />
<CheckBox Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="5 5 0 0" IsThreeState="True" Content="{x:Static p:dnSpy_AsmEditor_Resources.SaveModule_TablesHeap_UseENC}" IsChecked="{Binding MetadataOptions.TablesHeapOptions.UseENC}" />
</Grid>
</GroupBox>
</StackPanel>

View File

@ -140,18 +140,18 @@ namespace dnSpy.AsmEditor.SaveModule {
public PEHeadersOptionsVM PEHeadersOptions { get; }
public Cor20HeaderOptionsVM Cor20HeaderOptions { get; }
public MetaDataOptionsVM MetaDataOptions { get; }
public MetadataOptionsVM MetadataOptions { get; }
public SaveModuleOptionsVM(IDsDocument document) {
this.document = document;
Module = document.ModuleDef;
PEHeadersOptions = new PEHeadersOptionsVM(Module.Machine, GetSubsystem(Module.Kind));
Cor20HeaderOptions = new Cor20HeaderOptionsVM();
MetaDataOptions = new MetaDataOptionsVM();
MetadataOptions = new MetadataOptionsVM();
PEHeadersOptions.PropertyChanged += (s, e) => HasErrorUpdated();
Cor20HeaderOptions.PropertyChanged += (s, e) => HasErrorUpdated();
MetaDataOptions.PropertyChanged += (s, e) => HasErrorUpdated();
MetadataOptions.PropertyChanged += (s, e) => HasErrorUpdated();
ModuleKind = new EnumListVM(moduleKindList, (a, b) => {
OnPropertyChanged(nameof(Extension));
@ -204,7 +204,7 @@ namespace dnSpy.AsmEditor.SaveModule {
void CopyTo(ModuleWriterOptionsBase options) {
PEHeadersOptions.CopyTo(options.PEHeadersOptions);
Cor20HeaderOptions.CopyTo(options.Cor20HeaderOptions);
MetaDataOptions.CopyTo(options.MetaDataOptions);
MetadataOptions.CopyTo(options.MetadataOptions);
options.WritePdb = WritePdb;
options.ShareMethodBodies = ShareMethodBodies;
@ -247,7 +247,7 @@ namespace dnSpy.AsmEditor.SaveModule {
PEHeadersOptions.InitializeFrom(options.PEHeadersOptions);
Cor20HeaderOptions.InitializeFrom(options.Cor20HeaderOptions);
MetaDataOptions.InitializeFrom(options.MetaDataOptions);
MetadataOptions.InitializeFrom(options.MetadataOptions);
WritePdb = options.WritePdb;
ShareMethodBodies = options.ShareMethodBodies;
@ -265,7 +265,7 @@ namespace dnSpy.AsmEditor.SaveModule {
return base.HasError ||
PEHeadersOptions.HasError ||
Cor20HeaderOptions.HasError ||
MetaDataOptions.HasError;
MetadataOptions.HasError;
}
}
}
@ -377,8 +377,8 @@ namespace dnSpy.AsmEditor.SaveModule {
}
public bool? Bit32Machine {
get => GetFlagValue(dnlib.PE.Characteristics._32BitMachine);
set => SetFlagValue(dnlib.PE.Characteristics._32BitMachine, value);
get => GetFlagValue(dnlib.PE.Characteristics.Bit32Machine);
set => SetFlagValue(dnlib.PE.Characteristics.Bit32Machine, value);
}
public bool? DebugStripped {
@ -684,8 +684,8 @@ namespace dnSpy.AsmEditor.SaveModule {
}
public bool? Bit32Required {
get => GetFlagValue(ComImageFlags._32BitRequired);
set => SetFlagValue(ComImageFlags._32BitRequired, value);
get => GetFlagValue(ComImageFlags.Bit32Required);
set => SetFlagValue(ComImageFlags.Bit32Required, value);
}
public bool? ILLibrary {
@ -704,8 +704,8 @@ namespace dnSpy.AsmEditor.SaveModule {
}
public bool? Bit32Preferred {
get => GetFlagValue(ComImageFlags._32BitPreferred);
set => SetFlagValue(ComImageFlags._32BitPreferred, value);
get => GetFlagValue(ComImageFlags.Bit32Preferred);
set => SetFlagValue(ComImageFlags.Bit32Preferred, value);
}
bool? GetFlagValue(ComImageFlags flag) => Flags == null ? (bool?)null : (Flags.Value & flag) != 0;
@ -744,19 +744,19 @@ namespace dnSpy.AsmEditor.SaveModule {
}
}
sealed class MetaDataOptionsVM : ViewModelBase {
public MetaDataOptionsVM() {
MetaDataHeaderOptions = new MetaDataHeaderOptionsVM();
sealed class MetadataOptionsVM : ViewModelBase {
public MetadataOptionsVM() {
MetadataHeaderOptions = new MetadataHeaderOptionsVM();
TablesHeapOptions = new TablesHeapOptionsVM();
MetaDataHeaderOptions.PropertyChanged += (s, e) => HasErrorUpdated();
MetadataHeaderOptions.PropertyChanged += (s, e) => HasErrorUpdated();
TablesHeapOptions.PropertyChanged += (s, e) => HasErrorUpdated();
}
public MetaDataHeaderOptionsVM MetaDataHeaderOptions { get; }
public MetadataHeaderOptionsVM MetadataHeaderOptions { get; }
public TablesHeapOptionsVM TablesHeapOptions { get; }
public MetaDataFlags Flags {
public MetadataFlags Flags {
get => flags;
set {
if (flags != value) {
@ -765,67 +765,67 @@ namespace dnSpy.AsmEditor.SaveModule {
}
}
}
MetaDataFlags flags;
MetadataFlags flags;
public bool PreserveTypeRefRids {
get => GetFlagValue(MetaDataFlags.PreserveTypeRefRids);
set => SetFlagValue(MetaDataFlags.PreserveTypeRefRids, value, nameof(PreserveRids), nameof(PreserveTypeRefRids));
get => GetFlagValue(MetadataFlags.PreserveTypeRefRids);
set => SetFlagValue(MetadataFlags.PreserveTypeRefRids, value, nameof(PreserveRids), nameof(PreserveTypeRefRids));
}
public bool PreserveTypeDefRids {
get => GetFlagValue(MetaDataFlags.PreserveTypeDefRids);
set => SetFlagValue(MetaDataFlags.PreserveTypeDefRids, value, nameof(PreserveRids), nameof(PreserveTypeDefRids));
get => GetFlagValue(MetadataFlags.PreserveTypeDefRids);
set => SetFlagValue(MetadataFlags.PreserveTypeDefRids, value, nameof(PreserveRids), nameof(PreserveTypeDefRids));
}
public bool PreserveFieldRids {
get => GetFlagValue(MetaDataFlags.PreserveFieldRids);
set => SetFlagValue(MetaDataFlags.PreserveFieldRids, value, nameof(PreserveRids), nameof(PreserveFieldRids));
get => GetFlagValue(MetadataFlags.PreserveFieldRids);
set => SetFlagValue(MetadataFlags.PreserveFieldRids, value, nameof(PreserveRids), nameof(PreserveFieldRids));
}
public bool PreserveMethodRids {
get => GetFlagValue(MetaDataFlags.PreserveMethodRids);
set => SetFlagValue(MetaDataFlags.PreserveMethodRids, value, nameof(PreserveRids), nameof(PreserveMethodRids));
get => GetFlagValue(MetadataFlags.PreserveMethodRids);
set => SetFlagValue(MetadataFlags.PreserveMethodRids, value, nameof(PreserveRids), nameof(PreserveMethodRids));
}
public bool PreserveParamRids {
get => GetFlagValue(MetaDataFlags.PreserveParamRids);
set => SetFlagValue(MetaDataFlags.PreserveParamRids, value, nameof(PreserveRids), nameof(PreserveParamRids));
get => GetFlagValue(MetadataFlags.PreserveParamRids);
set => SetFlagValue(MetadataFlags.PreserveParamRids, value, nameof(PreserveRids), nameof(PreserveParamRids));
}
public bool PreserveMemberRefRids {
get => GetFlagValue(MetaDataFlags.PreserveMemberRefRids);
set => SetFlagValue(MetaDataFlags.PreserveMemberRefRids, value, nameof(PreserveRids), nameof(PreserveMemberRefRids));
get => GetFlagValue(MetadataFlags.PreserveMemberRefRids);
set => SetFlagValue(MetadataFlags.PreserveMemberRefRids, value, nameof(PreserveRids), nameof(PreserveMemberRefRids));
}
public bool PreserveStandAloneSigRids {
get => GetFlagValue(MetaDataFlags.PreserveStandAloneSigRids);
set => SetFlagValue(MetaDataFlags.PreserveStandAloneSigRids, value, nameof(PreserveRids), nameof(PreserveStandAloneSigRids));
get => GetFlagValue(MetadataFlags.PreserveStandAloneSigRids);
set => SetFlagValue(MetadataFlags.PreserveStandAloneSigRids, value, nameof(PreserveRids), nameof(PreserveStandAloneSigRids));
}
public bool PreserveEventRids {
get => GetFlagValue(MetaDataFlags.PreserveEventRids);
set => SetFlagValue(MetaDataFlags.PreserveEventRids, value, nameof(PreserveRids), nameof(PreserveEventRids));
get => GetFlagValue(MetadataFlags.PreserveEventRids);
set => SetFlagValue(MetadataFlags.PreserveEventRids, value, nameof(PreserveRids), nameof(PreserveEventRids));
}
public bool PreservePropertyRids {
get => GetFlagValue(MetaDataFlags.PreservePropertyRids);
set => SetFlagValue(MetaDataFlags.PreservePropertyRids, value, nameof(PreserveRids), nameof(PreservePropertyRids));
get => GetFlagValue(MetadataFlags.PreservePropertyRids);
set => SetFlagValue(MetadataFlags.PreservePropertyRids, value, nameof(PreserveRids), nameof(PreservePropertyRids));
}
public bool PreserveTypeSpecRids {
get => GetFlagValue(MetaDataFlags.PreserveTypeSpecRids);
set => SetFlagValue(MetaDataFlags.PreserveTypeSpecRids, value, nameof(PreserveRids), nameof(PreserveTypeSpecRids));
get => GetFlagValue(MetadataFlags.PreserveTypeSpecRids);
set => SetFlagValue(MetadataFlags.PreserveTypeSpecRids, value, nameof(PreserveRids), nameof(PreserveTypeSpecRids));
}
public bool PreserveMethodSpecRids {
get => GetFlagValue(MetaDataFlags.PreserveMethodSpecRids);
set => SetFlagValue(MetaDataFlags.PreserveMethodSpecRids, value, nameof(PreserveRids), nameof(PreserveMethodSpecRids));
get => GetFlagValue(MetadataFlags.PreserveMethodSpecRids);
set => SetFlagValue(MetadataFlags.PreserveMethodSpecRids, value, nameof(PreserveRids), nameof(PreserveMethodSpecRids));
}
public bool? PreserveRids {
get {
var val = Flags & MetaDataFlags.PreserveRids;
if (val == MetaDataFlags.PreserveRids)
var val = Flags & MetadataFlags.PreserveRids;
if (val == MetadataFlags.PreserveRids)
return true;
if (val == 0)
return false;
@ -834,9 +834,9 @@ namespace dnSpy.AsmEditor.SaveModule {
set {
if (value != null && value != PreserveRids) {
if (value.Value)
Flags |= MetaDataFlags.PreserveRids;
Flags |= MetadataFlags.PreserveRids;
else
Flags &= ~MetaDataFlags.PreserveRids;
Flags &= ~MetadataFlags.PreserveRids;
OnPropertyChanged(nameof(PreserveRids));
OnPropertyChanged(nameof(PreserveTypeRefRids));
OnPropertyChanged(nameof(PreserveTypeDefRids));
@ -854,53 +854,53 @@ namespace dnSpy.AsmEditor.SaveModule {
}
public bool PreserveStringsOffsets {
get => GetFlagValue(MetaDataFlags.PreserveStringsOffsets);
set => SetFlagValue(MetaDataFlags.PreserveStringsOffsets, value, nameof(PreserveStringsOffsets));
get => GetFlagValue(MetadataFlags.PreserveStringsOffsets);
set => SetFlagValue(MetadataFlags.PreserveStringsOffsets, value, nameof(PreserveStringsOffsets));
}
public bool PreserveUSOffsets {
get => GetFlagValue(MetaDataFlags.PreserveUSOffsets);
set => SetFlagValue(MetaDataFlags.PreserveUSOffsets, value, nameof(PreserveUSOffsets));
get => GetFlagValue(MetadataFlags.PreserveUSOffsets);
set => SetFlagValue(MetadataFlags.PreserveUSOffsets, value, nameof(PreserveUSOffsets));
}
public bool PreserveBlobOffsets {
get => GetFlagValue(MetaDataFlags.PreserveBlobOffsets);
set => SetFlagValue(MetaDataFlags.PreserveBlobOffsets, value, nameof(PreserveBlobOffsets));
get => GetFlagValue(MetadataFlags.PreserveBlobOffsets);
set => SetFlagValue(MetadataFlags.PreserveBlobOffsets, value, nameof(PreserveBlobOffsets));
}
public bool PreserveExtraSignatureData {
get => GetFlagValue(MetaDataFlags.PreserveExtraSignatureData);
set => SetFlagValue(MetaDataFlags.PreserveExtraSignatureData, value, nameof(PreserveExtraSignatureData));
get => GetFlagValue(MetadataFlags.PreserveExtraSignatureData);
set => SetFlagValue(MetadataFlags.PreserveExtraSignatureData, value, nameof(PreserveExtraSignatureData));
}
public bool KeepOldMaxStack {
get => GetFlagValue(MetaDataFlags.KeepOldMaxStack);
set => SetFlagValue(MetaDataFlags.KeepOldMaxStack, value, nameof(KeepOldMaxStack));
get => GetFlagValue(MetadataFlags.KeepOldMaxStack);
set => SetFlagValue(MetadataFlags.KeepOldMaxStack, value, nameof(KeepOldMaxStack));
}
public bool AlwaysCreateGuidHeap {
get => GetFlagValue(MetaDataFlags.AlwaysCreateGuidHeap);
set => SetFlagValue(MetaDataFlags.AlwaysCreateGuidHeap, value, nameof(AlwaysCreateGuidHeap));
get => GetFlagValue(MetadataFlags.AlwaysCreateGuidHeap);
set => SetFlagValue(MetadataFlags.AlwaysCreateGuidHeap, value, nameof(AlwaysCreateGuidHeap));
}
public bool AlwaysCreateStringsHeap {
get => GetFlagValue(MetaDataFlags.AlwaysCreateStringsHeap);
set => SetFlagValue(MetaDataFlags.AlwaysCreateStringsHeap, value, nameof(AlwaysCreateStringsHeap));
get => GetFlagValue(MetadataFlags.AlwaysCreateStringsHeap);
set => SetFlagValue(MetadataFlags.AlwaysCreateStringsHeap, value, nameof(AlwaysCreateStringsHeap));
}
public bool AlwaysCreateUSHeap {
get => GetFlagValue(MetaDataFlags.AlwaysCreateUSHeap);
set => SetFlagValue(MetaDataFlags.AlwaysCreateUSHeap, value, nameof(AlwaysCreateUSHeap));
get => GetFlagValue(MetadataFlags.AlwaysCreateUSHeap);
set => SetFlagValue(MetadataFlags.AlwaysCreateUSHeap, value, nameof(AlwaysCreateUSHeap));
}
public bool AlwaysCreateBlobHeap {
get => GetFlagValue(MetaDataFlags.AlwaysCreateBlobHeap);
set => SetFlagValue(MetaDataFlags.AlwaysCreateBlobHeap, value, nameof(AlwaysCreateBlobHeap));
get => GetFlagValue(MetadataFlags.AlwaysCreateBlobHeap);
set => SetFlagValue(MetadataFlags.AlwaysCreateBlobHeap, value, nameof(AlwaysCreateBlobHeap));
}
bool GetFlagValue(MetaDataFlags flag) => (Flags & flag) != 0;
bool GetFlagValue(MetadataFlags flag) => (Flags & flag) != 0;
void SetFlagValue(MetaDataFlags flag, bool value, string prop1, string prop2 = null) {
void SetFlagValue(MetadataFlags flag, bool value, string prop1, string prop2 = null) {
bool origValue = (Flags & flag) != 0;
if (origValue == value)
return;
@ -915,14 +915,14 @@ namespace dnSpy.AsmEditor.SaveModule {
OnPropertyChanged(prop2);
}
public void CopyTo(MetaDataOptions options) {
MetaDataHeaderOptions.CopyTo(options.MetaDataHeaderOptions);
public void CopyTo(MetadataOptions options) {
MetadataHeaderOptions.CopyTo(options.MetadataHeaderOptions);
TablesHeapOptions.CopyTo(options.TablesHeapOptions);
options.Flags = Flags;
}
public void InitializeFrom(MetaDataOptions options) {
MetaDataHeaderOptions.InitializeFrom(options.MetaDataHeaderOptions);
public void InitializeFrom(MetadataOptions options) {
MetadataHeaderOptions.InitializeFrom(options.MetadataHeaderOptions);
TablesHeapOptions.InitializeFrom(options.TablesHeapOptions);
Flags = options.Flags;
OnFlagsChanged();
@ -954,14 +954,14 @@ namespace dnSpy.AsmEditor.SaveModule {
public override bool HasError {
get {
return MetaDataHeaderOptions.HasError ||
return MetadataHeaderOptions.HasError ||
TablesHeapOptions.HasError;
}
}
}
sealed class MetaDataHeaderOptionsVM : ViewModelBase {
public MetaDataHeaderOptionsVM() {
sealed class MetadataHeaderOptionsVM : ViewModelBase {
public MetadataHeaderOptionsVM() {
Signature = new NullableUInt32VM(a => HasErrorUpdated());
MajorVersion = new NullableUInt16VM(a => HasErrorUpdated());
MinorVersion = new NullableUInt16VM(a => HasErrorUpdated());
@ -988,7 +988,7 @@ namespace dnSpy.AsmEditor.SaveModule {
public NullableByteVM StorageFlags { get; }
public NullableByteVM Reserved2 { get; }
public void CopyTo(MetaDataHeaderOptions options) {
public void CopyTo(MetadataHeaderOptions options) {
options.Signature = Signature.Value;
options.MajorVersion = MajorVersion.Value;
options.MinorVersion = MinorVersion.Value;
@ -998,7 +998,7 @@ namespace dnSpy.AsmEditor.SaveModule {
options.Reserved2 = Reserved2.Value;
}
public void InitializeFrom(MetaDataHeaderOptions options) {
public void InitializeFrom(MetadataHeaderOptions options) {
Signature.Value = options.Signature;
MajorVersion.Value = options.MajorVersion;
MinorVersion.Value = options.MinorVersion;

View File

@ -155,6 +155,7 @@
<Compile Include="Compiler\MDEditor\MDWriterStream.cs" />
<Compile Include="Compiler\MDEditor\MetadataEditor.cs" />
<Compile Include="Compiler\MDEditor\PESectionData.cs" />
<Compile Include="Compiler\MDEditor\RawRowColumnReader.cs" />
<Compile Include="Compiler\MDEditor\SectionSizes.cs" />
<Compile Include="Compiler\MDEditor\StringsHeapWriter.cs" />
<Compile Include="Compiler\MDEditor\StringsMDHeap.cs" />
@ -383,8 +384,8 @@
<Compile Include="Hex\Nodes\ImageOptionalHeader32Node.cs" />
<Compile Include="Hex\Nodes\ImageOptionalHeader64Node.cs" />
<Compile Include="Hex\Nodes\ImageSectionHeaderNode.cs" />
<Compile Include="Hex\Nodes\MetaDataTableNode.cs" />
<Compile Include="Hex\Nodes\MetaDataTableRecordNode.cs" />
<Compile Include="Hex\Nodes\MetadataTableNode.cs" />
<Compile Include="Hex\Nodes\MetadataTableRecordNode.cs" />
<Compile Include="Hex\Nodes\PENode.cs" />
<Compile Include="Hex\Nodes\PETreeNodeDataProvider.cs" />
<Compile Include="Hex\Nodes\StorageHeaderNode.cs" />
@ -406,8 +407,8 @@
<Compile Include="Hex\PE\ImageOptionalHeader64VM.cs" />
<Compile Include="Hex\PE\ImageOptionalHeaderVM.cs" />
<Compile Include="Hex\PE\ImageSectionHeaderVM.cs" />
<Compile Include="Hex\PE\MetaDataTableRecordVM.cs" />
<Compile Include="Hex\PE\MetaDataTableVM.cs" />
<Compile Include="Hex\PE\MetadataTableRecordVM.cs" />
<Compile Include="Hex\PE\MetadataTableVM.cs" />
<Compile Include="Hex\PE\PEStructureProvider.cs" />
<Compile Include="Hex\PE\StorageHeaderVM.cs" />
<Compile Include="Hex\PE\StorageSignatureVM.cs" />

View File

@ -120,7 +120,7 @@ namespace dnSpy.Debugger.DotNet.CorDebug.Impl.Evaluation {
var resultStream = new MemoryStream();
var options = new ModuleWriterOptions(md);
options.MetaDataOptions.Flags = MetaDataFlags.PreserveRids;
options.MetadataOptions.Flags = MetadataFlags.PreserveRids;
md.Write(resultStream, options);
state.Module = null;

View File

@ -200,9 +200,8 @@ namespace dnSpy.Debugger.DotNet.CorDebug.Impl {
}
}
else {
using (var md = MetaDataCreator.CreateMetaData(peImage)) {
var row = md.TablesStream.ReadAssemblyRow(1);
if (row == null)
using (var md = MetadataCreator.CreateMetadata(peImage)) {
if (!md.TablesStream.TryReadAssemblyRow(1, out var row))
assemblySimpleName = null;
else
assemblySimpleName = md.StringsStream.Read(row.Name);

View File

@ -107,7 +107,7 @@ namespace dndbg.DotNet {
//genericParamConstraints?.Clear();
var itemTokens = MDAPI.GetGenericParamConstraintTokens(mdi2, token);
genericParamConstraints = new LazyList<GenericParamConstraint>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => readerModule.ResolveGenericParamConstraintDontCache(itemTokens[index], GetGenericParamContext(owner)));
genericParamConstraints = new LazyList<GenericParamConstraint, uint[]>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => readerModule.ResolveGenericParamConstraintDontCache(itemTokens2[index], GetGenericParamContext(owner)));
}
}
}

View File

@ -153,7 +153,7 @@ namespace dndbg.DotNet {
newItems[i] = readerModule.Register(new CorParamDef(readerModule, itemRid, this), cmd => cmd.Initialize());
}
paramDefs = new LazyList<ParamDef>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => newItems[index].Item);
paramDefs = new LazyList<ParamDef, MemberInfo<CorParamDef>[]>(itemTokens.Length, this, newItems, (newItems2, index) => newItems2[index].Item);
}
public void UpdateGenericParams() {
@ -176,7 +176,7 @@ namespace dndbg.DotNet {
newItems[i] = readerModule.Register(new CorGenericParam(readerModule, itemRid, this), cmd => cmd.Initialize());
}
genericParameters = new LazyList<GenericParam>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => newItems[index].Item);
genericParameters = new LazyList<GenericParam, MemberInfo<CorGenericParam>[]>(itemTokens.Length, this, newItems, (newItems2, index) => newItems2[index].Item);
}
protected override void InitializeOverrides() {

View File

@ -307,7 +307,7 @@ namespace dndbg.DotNet {
internal void InitCustomAttributes(ICorHasCustomAttribute hca, ref CustomAttributeCollection customAttributes, GenericParamContext gpContext) {
var tokens = MDAPI.GetCustomAttributeTokens(mdi, hca.OriginalToken.Raw);
var tmp = new CustomAttributeCollection(tokens.Length, tokens, (tokens2, index) => ReadCustomAttribute(tokens[index], gpContext));
var tmp = new CustomAttributeCollection(tokens.Length, tokens, (tokens2, index) => ReadCustomAttribute(((uint[])tokens2)[index], gpContext));
Interlocked.CompareExchange(ref customAttributes, tmp, null);
}
@ -321,7 +321,7 @@ namespace dndbg.DotNet {
internal void InitDeclSecurities(ICorHasDeclSecurity hds, ref IList<DeclSecurity> declSecurities) {
var tokens = MDAPI.GetPermissionSetTokens(mdi, hds.OriginalToken.Raw);
var tmp = new LazyList<DeclSecurity>(tokens.Length, tokens, (tokens2, index) => ResolveDeclSecurity(tokens[index]));
var tmp = new LazyList<DeclSecurity, uint[]>(tokens.Length, tokens, (tokens2, index) => ResolveDeclSecurity(tokens2[index]));
Interlocked.CompareExchange(ref declSecurities, tmp, null);
}
@ -369,14 +369,14 @@ namespace dndbg.DotNet {
// Only one of these two bits can be set
if ((peKind & CorPEKind.pe32BitRequired) != 0)
Cor20HeaderFlags |= ComImageFlags._32BitRequired;
Cor20HeaderFlags |= ComImageFlags.Bit32Required;
else if ((peKind & CorPEKind.pe32BitPreferred) != 0)
Cor20HeaderFlags |= ComImageFlags._32BitRequired | ComImageFlags._32BitPreferred;
Cor20HeaderFlags |= ComImageFlags.Bit32Required | ComImageFlags.Bit32Preferred;
if (mach == Machine.AMD64 || mach == Machine.ARM64 || mach == Machine.IA64 || (peKind & CorPEKind.pe32BitRequired) == 0)
Characteristics |= Characteristics.LargeAddressAware;
else
Characteristics |= Characteristics._32BitMachine;
Characteristics |= Characteristics.Bit32Machine;
}
if (Kind != ModuleKind.NetModule) {
@ -948,7 +948,7 @@ namespace dndbg.DotNet {
protected override void InitializeTypes() {
var list = GetNonNestedClassRids();
var tmp = new LazyList<TypeDef>(list.Length, this, list, (list2, index) => ResolveTypeDef(((uint[])list2)[index]));
var tmp = new LazyList<TypeDef, uint[]>(list.Length, this, list, (list2, index) => ResolveTypeDef(list2[index]));
Interlocked.CompareExchange(ref types, tmp, null);
}
@ -1080,7 +1080,7 @@ namespace dndbg.DotNet {
protected override void InitializeExportedTypes() {
var list = MDAPI.GetExportedTypeRids(MetaDataAssemblyImport);
var tmp = new LazyList<ExportedType>(list.Length, list, (list2, i) => ResolveExportedType(((uint[])list2)[i]));
var tmp = new LazyList<ExportedType, uint[]>(list.Length, list, (list2, i) => ResolveExportedType(list2[i]));
Interlocked.CompareExchange(ref exportedTypes, tmp, null);
lastExportedTypeRidInList = list.Length == 0 ? 0 : list.Max();
}
@ -1114,7 +1114,7 @@ namespace dndbg.DotNet {
protected override void InitializeResources() {
var list = MDAPI.GetManifestResourceRids(MetaDataAssemblyImport);
var tmp = new ResourceCollection(list.Length, null, (ctx, i) => CreateResource(i + 1));
var tmp = new ResourceCollection(list.Length, null, (ctx, i) => CreateResource((uint)i + 1));
Interlocked.CompareExchange(ref resources, tmp, null);
lastManifestResourceRidInList = list.Length == 0 ? 0 : list.Max();
}

View File

@ -144,7 +144,7 @@ namespace dndbg.DotNet {
newItems[i] = readerModule.Register(new CorFieldDef(readerModule, itemRid, this), cmd => cmd.Initialize());
}
fields = new LazyList<FieldDef>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => newItems[index].Item);
fields = new LazyList<FieldDef, MemberInfo<CorFieldDef>[]>(itemTokens.Length, this, newItems, (newItems2, index) => newItems2[index].Item);
}
public void UpdateMethods() {
@ -167,7 +167,7 @@ namespace dndbg.DotNet {
newItems[i] = readerModule.Register(new CorMethodDef(readerModule, itemRid, this), cmd => cmd.Initialize());
}
methods = new LazyList<MethodDef>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => newItems[index].Item);
methods = new LazyList<MethodDef, MemberInfo<CorMethodDef>[]>(itemTokens.Length, this, newItems, (newItems2, index) => newItems2[index].Item);
}
public void UpdateGenericParams() {
@ -190,7 +190,7 @@ namespace dndbg.DotNet {
newItems[i] = readerModule.Register(new CorGenericParam(readerModule, itemRid, this), cmd => cmd.Initialize());
}
genericParameters = new LazyList<GenericParam>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => newItems[index].Item);
genericParameters = new LazyList<GenericParam, MemberInfo<CorGenericParam>[]>(itemTokens.Length, this, newItems, (newItems2, index) => newItems2[index].Item);
}
public void UpdateProperties() {
@ -213,7 +213,7 @@ namespace dndbg.DotNet {
newItems[i] = readerModule.Register(new CorPropertyDef(readerModule, itemRid, this), cmd => cmd.Initialize());
}
properties = new LazyList<PropertyDef>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => newItems[index].Item);
properties = new LazyList<PropertyDef, MemberInfo<CorPropertyDef>[]>(itemTokens.Length, this, newItems, (newItems2, index) => newItems2[index].Item);
}
public void UpdateEvents() {
@ -236,7 +236,7 @@ namespace dndbg.DotNet {
newItems[i] = readerModule.Register(new CorEventDef(readerModule, itemRid, this), cmd => cmd.Initialize());
}
events = new LazyList<EventDef>(itemTokens.Length, this, itemTokens, (itemTokens2, index) => newItems[index].Item);
events = new LazyList<EventDef, MemberInfo<CorEventDef>[]>(itemTokens.Length, this, newItems, (newItems2, index) => newItems2[index].Item);
}
void InitInterfaceImpls_NoLock() {
@ -246,7 +246,7 @@ namespace dndbg.DotNet {
interfaces?.Clear();
var itemTokens = MDAPI.GetInterfaceImplTokens(mdi, token);
interfaces = new LazyList<InterfaceImpl>(itemTokens.Length, itemTokens, (itemTokens2, index) => readerModule.ResolveInterfaceImpl(itemTokens[index], new GenericParamContext(this)));
interfaces = new LazyList<InterfaceImpl, uint[]>(itemTokens.Length, itemTokens, (itemTokens2, index) => readerModule.ResolveInterfaceImpl(itemTokens2[index], new GenericParamContext(this)));
}
void InitCustomAttributes_NoLock() => customAttributes = null;
@ -408,7 +408,7 @@ namespace dndbg.DotNet {
protected override void InitializeNestedTypes() {
var list = readerModule.GetTypeDefNestedClassRids(this);
var tmp = new LazyList<TypeDef>(list.Length, this, list, (list2, index) => readerModule.ResolveTypeDef(((uint[])list2)[index]));
var tmp = new LazyList<TypeDef, uint[]>(list.Length, this, list, (list2, index) => readerModule.ResolveTypeDef(list2[index]));
Interlocked.CompareExchange(ref nestedTypes, tmp, null);
}
}

View File

@ -173,7 +173,7 @@ namespace dndbg.Engine {
using (var mod = ModuleDefMD.Load(peImage)) {
var file = mod.ResolveFile(token & 0x00FFFFFF);
if (file == null || !file.ContainsMetaData)
if (file == null || !file.ContainsMetadata)
return 0;
otherModuleName = file.Name;

View File

@ -58,12 +58,12 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
Create(module, File.ReadAllBytes(filename), isFileLayout);
static DmdEcma335MetadataReader Create(DmdModuleImpl module, IPEImage peImage) {
var metadata = MetaDataCreator.CreateMetaData(peImage);
var metadata = MetadataCreator.CreateMetadata(peImage);
return new DmdEcma335MetadataReader(module, metadata);
}
internal DmdModule Module => module;
internal IMetaData Metadata { get; }
internal dnlib.DotNet.MD.Metadata Metadata { get; }
internal TablesStream TablesStream => Metadata.TablesStream;
internal StringsStream StringsStream => Metadata.StringsStream;
internal GuidStream GuidStream => Metadata.GuidStream;
@ -84,16 +84,16 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
readonly Dictionary<uint, DmdType> fieldTypeCache;
readonly Dictionary<uint, DmdMethodSignature> methodSignatureCache;
DmdEcma335MetadataReader(DmdModuleImpl module, IMetaData metadata) {
DmdEcma335MetadataReader(DmdModuleImpl module, dnlib.DotNet.MD.Metadata metadata) {
signatureLock = new object();
this.module = module;
Metadata = metadata;
fieldTypeCache = new Dictionary<uint, DmdType>();
methodSignatureCache = new Dictionary<uint, DmdMethodSignature>();
var row = TablesStream.ReadModuleRow(1);
ModuleScopeName = metadata.StringsStream.ReadNoNull(row?.Name ?? 0);
ModuleVersionId = metadata.GuidStream.Read(row?.Mvid ?? 0) ?? Guid.Empty;
TablesStream.TryReadModuleRow(1, out var row);
ModuleScopeName = metadata.StringsStream.ReadNoNull(row.Name);
ModuleVersionId = metadata.GuidStream.Read(row.Mvid) ?? Guid.Empty;
var ts = TablesStream;
typeRefList = new LazyList<DmdTypeRef>(ts.TypeRefTable.Rows, rid => new DmdTypeRefMD(this, rid, null));
@ -110,7 +110,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
}
(DmdType type, bool containedGenericParams) ReadTypeSpec(uint rid, IList<DmdType> genericTypeArguments, IList<DmdType> genericMethodArguments) {
var row = Metadata.TablesStream.ReadTypeSpecRow(rid);
Metadata.TablesStream.TryReadTypeSpecRow(rid, out var row);
using (var stream = BlobStream.CreateStream(row.Signature))
return DmdSignatureReader.ReadTypeSignature(module, new DmdDataStreamImpl(stream), genericTypeArguments, genericMethodArguments, resolveTypes);
}
@ -172,7 +172,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
}
DmdMethodBase CreateMethodDefCore(uint rid, DmdType declaringType, DmdType reflectedType) {
var row = TablesStream.ReadMethodRow(rid);
TablesStream.TryReadMethodRow(rid, out var row);
string name = StringsStream.ReadNoNull(row.Name);
if ((row.Flags & (int)DmdMethodAttributes.RTSpecialName) != 0 && name.Length > 0 && name[0] == '.') {
if (name == DmdConstructorInfo.ConstructorName || name == DmdConstructorInfo.TypeConstructorName)
@ -214,7 +214,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
var parameters = sigParamTypes.Count == 0 ? Array.Empty<DmdParameterInfo>() : new DmdParameterInfo[sigParamTypes.Count];
for (int i = 0; i < ridList.Count; i++) {
uint rid = ridList[i];
var row = TablesStream.ReadParamRow(rid);
TablesStream.TryReadParamRow(rid, out var row);
var name = StringsStream.Read(row.Name);
if (row.Sequence == 0) {
if (createReturnParameter && (object)returnParameter == null)
@ -279,7 +279,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
var genericParams = new DmdType[ridList.Count];
for (int i = 0; i < genericParams.Length; i++) {
uint rid = ridList[i];
var row = TablesStream.ReadGenericParamRow(rid) ?? new RawGenericParamRow();
TablesStream.TryReadGenericParamRow(rid, out var row);
var gpName = StringsStream.ReadNoNull(row.Name);
var gpType = new DmdGenericParameterTypeMD(this, rid, method, gpName, row.Number, (DmdGenericParameterAttributes)row.Flags, null);
genericParams[i] = gpType;
@ -288,7 +288,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
}
(DmdMemberInfo member, bool containedGenericParams) CreateResolvedMemberRef(uint rid, IList<DmdType> genericTypeArguments, IList<DmdType> genericMethodArguments) {
var row = TablesStream.ReadMemberRefRow(rid);
TablesStream.TryReadMemberRefRow(rid, out var row);
var name = StringsStream.ReadNoNull(row.Name);
if (!CodedToken.MemberRefParent.Decode(row.Class, out uint classToken))
@ -330,8 +330,8 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
return ResolveType((int)classToken, genericTypeArguments, genericMethodArguments, DmdResolveOptions.None) ?? Module.AppDomain.System_Void;
case Table.ModuleRef:
var moduleRefRow = TablesStream.ReadModuleRefRow(classToken & 0x00FFFFFF);
var moduleName = StringsStream.ReadNoNull(moduleRefRow?.Name ?? 0);
TablesStream.TryReadModuleRefRow(classToken & 0x00FFFFFF, out var moduleRefRow);
var moduleName = StringsStream.ReadNoNull(moduleRefRow.Name);
if (StringComparer.OrdinalIgnoreCase.Equals(moduleName, Module.ScopeName))
return Module.GlobalType;
var referencedModule = Module.Assembly.GetModule(moduleName);
@ -391,8 +391,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
internal DmdMethodBody GetMethodBody(DmdMethodBase method, IList<DmdType> genericTypeArguments, IList<DmdType> genericMethodArguments) {
if ((method.MethodImplementationFlags & DmdMethodImplAttributes.CodeTypeMask) != DmdMethodImplAttributes.IL)
return null;
var row = TablesStream.ReadMethodRow((uint)method.MetadataToken & 0x00FFFFFF);
if (row == null)
if (!TablesStream.TryReadMethodRow((uint)method.MetadataToken & 0x00FFFFFF, out var row))
return null;
if (row.RVA == 0)
return null;
@ -406,16 +405,15 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
}
internal uint GetRVA(DmdMethodBase method) {
var row = TablesStream.ReadMethodRow((uint)method.MetadataToken & 0x00FFFFFF);
return row?.RVA ?? 0;
TablesStream.TryReadMethodRow((uint)method.MetadataToken & 0x00FFFFFF, out var row);
return row.RVA;
}
(DmdType type, bool isPinned)[] IMethodBodyResolver.ReadLocals(int localSignatureMetadataToken, IList<DmdType> genericTypeArguments, IList<DmdType> genericMethodArguments) {
if ((localSignatureMetadataToken & 0x00FFFFFF) == 0 || (localSignatureMetadataToken >> 24) != 0x11)
return Array.Empty<(DmdType, bool)>();
uint rid = (uint)localSignatureMetadataToken & 0x00FFFFFF;
var row = TablesStream.ReadStandAloneSigRow(rid);
if (row == null)
if (!TablesStream.TryReadStandAloneSigRow(rid, out var row))
return Array.Empty<(DmdType, bool)>();
using (var stream = BlobStream.CreateStream(row.Signature))
return DmdSignatureReader.ReadLocalsSignature(module, new DmdDataStreamImpl(stream), genericTypeArguments, genericMethodArguments, resolveTypes);
@ -464,8 +462,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
protected override DmdType ResolveTypeSpec(uint rid, IList<DmdType> genericTypeArguments, IList<DmdType> genericMethodArguments) => typeSpecList[rid - 1, genericTypeArguments, genericMethodArguments];
protected override DmdTypeRef ResolveExportedType(uint rid) => exportedTypeList[rid - 1];
protected override DmdMethodBase ResolveMethodSpec(uint rid, IList<DmdType> genericTypeArguments, IList<DmdType> genericMethodArguments) {
var row = TablesStream.ReadMethodSpecRow(rid);
if (row == null)
if (!TablesStream.TryReadMethodSpecRow(rid, out var row))
return null;
DmdType[] instantiation;
using (var stream = BlobStream.CreateStream(row.Instantiation))
@ -479,50 +476,43 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
}
protected override DmdMethodSignature ResolveMethodSignature(uint rid, IList<DmdType> genericTypeArguments, IList<DmdType> genericMethodArguments) {
var row = TablesStream.ReadStandAloneSigRow(rid);
if (row == null)
if (!TablesStream.TryReadStandAloneSigRow(rid, out var row))
return null;
return ReadMethodSignature(row.Signature, genericTypeArguments, genericMethodArguments, isProperty: false);
}
protected override byte[] ResolveFieldSignature(uint rid) {
var row = TablesStream.ReadFieldRow(rid);
if (row == null)
if (!TablesStream.TryReadFieldRow(rid, out var row))
return null;
return Metadata.BlobStream.Read(row.Signature);
}
protected override byte[] ResolveMethodSignature(uint rid) {
var row = TablesStream.ReadMethodRow(rid);
if (row == null)
if (!TablesStream.TryReadMethodRow(rid, out var row))
return null;
return Metadata.BlobStream.Read(row.Signature);
}
protected override byte[] ResolveMemberRefSignature(uint rid) {
var row = TablesStream.ReadMemberRefRow(rid);
if (row == null)
if (!TablesStream.TryReadMemberRefRow(rid, out var row))
return null;
return Metadata.BlobStream.Read(row.Signature);
}
protected override byte[] ResolveStandAloneSigSignature(uint rid) {
var row = TablesStream.ReadStandAloneSigRow(rid);
if (row == null)
if (!TablesStream.TryReadStandAloneSigRow(rid, out var row))
return null;
return Metadata.BlobStream.Read(row.Signature);
}
protected override byte[] ResolveTypeSpecSignature(uint rid) {
var row = TablesStream.ReadTypeSpecRow(rid);
if (row == null)
if (!TablesStream.TryReadTypeSpecRow(rid, out var row))
return null;
return Metadata.BlobStream.Read(row.Signature);
}
protected override byte[] ResolveMethodSpecSignature(uint rid) {
var row = TablesStream.ReadMethodSpecRow(rid);
if (row == null)
if (!TablesStream.TryReadMethodSpecRow(rid, out var row))
return null;
return Metadata.BlobStream.Read(row.Instantiation);
}
@ -540,17 +530,16 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
// Hack for NGEN'd images
if ((Metadata.ImageCor20Header.Flags & ComImageFlags.ILLibrary) != 0)
peKind |= DmdPortableExecutableKinds.ILOnly;
if ((Metadata.ImageCor20Header.Flags & (ComImageFlags._32BitRequired | ComImageFlags._32BitPreferred)) == ComImageFlags._32BitRequired)
if ((Metadata.ImageCor20Header.Flags & (ComImageFlags.Bit32Required | ComImageFlags.Bit32Preferred)) == ComImageFlags.Bit32Required)
peKind |= DmdPortableExecutableKinds.Required32Bit;
else if ((Metadata.ImageCor20Header.Flags & (ComImageFlags._32BitRequired | ComImageFlags._32BitPreferred)) == (ComImageFlags._32BitRequired | ComImageFlags._32BitPreferred))
else if ((Metadata.ImageCor20Header.Flags & (ComImageFlags.Bit32Required | ComImageFlags.Bit32Preferred)) == (ComImageFlags.Bit32Required | ComImageFlags.Bit32Preferred))
peKind |= DmdPortableExecutableKinds.Preferred32Bit;
if (peKind == 0)
peKind = DmdPortableExecutableKinds.Required32Bit;
}
public override DmdReadOnlyAssemblyName GetName() {
var row = TablesStream.ReadAssemblyRow(1);
if (row == null)
if (!TablesStream.TryReadAssemblyRow(1, out var row))
return new DmdReadOnlyAssemblyName("no-asm-" + Guid.NewGuid().ToString(), null, null, 0, null, null, 0);
var version = new Version(row.MajorVersion, row.MinorVersion, row.BuildNumber, row.RevisionNumber);
@ -573,7 +562,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
}
internal DmdReadOnlyAssemblyName ReadAssemblyName(uint rid) {
var row = TablesStream.ReadAssemblyRefRow(rid) ?? new RawAssemblyRefRow();
TablesStream.TryReadAssemblyRefRow(rid, out var row);
var name = Metadata.StringsStream.ReadNoNull(row.Name);
var cultureName = Metadata.StringsStream.ReadNoNull(row.Locale);
var version = new Version(row.MajorVersion, row.MinorVersion, row.BuildNumber, row.RevisionNumber);
@ -615,8 +604,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
var res = new DmdCustomAttributeData[ridList.Count];
int w = 0;
for (int i = 0; i < ridList.Count; i++) {
var row = TablesStream.ReadCustomAttributeRow(ridList[i]);
if (row == null)
if (!TablesStream.TryReadCustomAttributeRow(ridList[i], out var row))
continue;
var ctor = ResolveCustomAttributeType(row.Type, null);
@ -649,8 +637,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
SSP.SecurityAction firstAction = 0;
List<(DmdCustomAttributeData[] cas, SSP.SecurityAction action)> res = null;
for (int i = 0; i < ridList.Count; i++) {
var row = TablesStream.ReadDeclSecurityRow(ridList[i]);
if (row == null)
if (!TablesStream.TryReadDeclSecurityRow(ridList[i], out var row))
continue;
var action = (SSP.SecurityAction)(row.Action & 0x1F);
DmdCustomAttributeData[] cas;
@ -692,8 +679,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
}
internal DmdMarshalType ReadMarshalType(int metadataToken, DmdModule module, IList<DmdType> genericTypeArguments) {
var row = TablesStream.ReadFieldMarshalRow(Metadata.GetFieldMarshalRid((Table)((uint)metadataToken >> 24), (uint)metadataToken & 0x00FFFFFF));
if (row == null)
if (!TablesStream.TryReadFieldMarshalRow(Metadata.GetFieldMarshalRid((Table)((uint)metadataToken >> 24), (uint)metadataToken & 0x00FFFFFF), out var row))
return null;
using (var stream = BlobStream.CreateStream(row.NativeType))
return DmdMarshalBlobReader.Read(module, new DmdDataStreamImpl(stream), genericTypeArguments);
@ -710,8 +696,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
var constantRid = Metadata.GetConstantRid((Table)((uint)metadataToken >> 24), (uint)(metadataToken & 0x00FFFFFF));
if (constantRid == 0)
return (null, false);
var row = TablesStream.ReadConstantRow(constantRid);
if (row == null)
if (!TablesStream.TryReadConstantRow(constantRid, out var row))
return (null, false);
return (MetadataConstantUtilities.GetValue((ElementType)row.Type, BlobStream.ReadNoNull(row.Value)), true);
}

View File

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using dnlib.DotNet;
using dnlib.DotNet.MD;
@ -32,7 +33,8 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
public DmdEventDefMD(DmdEcma335MetadataReader reader, uint rid, DmdType declaringType, DmdType reflectedType) : base(rid, declaringType, reflectedType) {
this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
var row = reader.TablesStream.ReadEventRow(rid);
bool b = reader.TablesStream.TryReadEventRow(rid, out var row);
Debug.Assert(b);
Name = reader.StringsStream.ReadNoNull(row.Name);
Attributes = (DmdEventAttributes)row.EventFlags;
if (!CodedToken.TypeDefOrRef.Decode(row.EventType, out uint token))
@ -47,8 +49,9 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
List<DmdMethodInfo> otherMethodsList = null;
var ridList = reader.Metadata.GetMethodSemanticsRidList(Table.Event, Rid);
for (uint i = 0; i < ridList.Length; i++) {
var row = reader.TablesStream.ReadMethodSemanticsRow(ridList[i]);
for (int i = 0; i < ridList.Count; i++) {
if (!reader.TablesStream.TryReadMethodSemanticsRow(ridList[i], out var row))
continue;
var method = ReflectedType.GetMethod(Module, 0x06000000 + (int)row.Method) as DmdMethodInfo;
if ((object)method == null)
continue;

View File

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using dnlib.DotNet.MD;
namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
@ -33,7 +34,8 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
public DmdExportedTypeMD(DmdEcma335MetadataReader reader, uint rid, IList<DmdCustomModifier> customModifiers) : base(reader.Module, rid, customModifiers) {
this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
var row = reader.TablesStream.ReadExportedTypeRow(rid);
bool b = reader.TablesStream.TryReadExportedTypeRow(rid, out var row);
Debug.Assert(b);
var ns = reader.StringsStream.Read(row.TypeNamespace);
MetadataNamespace = string.IsNullOrEmpty(ns) ? null : ns;
MetadataName = reader.StringsStream.ReadNoNull(row.TypeName);
@ -46,7 +48,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
break;
case 0x26:
var fileRow = reader.TablesStream.ReadFileRow(implToken & 0x00FFFFFF) ?? new RawFileRow();
reader.TablesStream.TryReadFileRow(implToken & 0x00FFFFFF, out var fileRow);
var moduleName = reader.StringsStream.ReadNoNull(fileRow.Name);
TypeScope = new DmdTypeScope(reader.GetName(), moduleName);
break;

View File

@ -18,6 +18,7 @@
*/
using System;
using System.Diagnostics;
namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
sealed class DmdFieldDefMD : DmdFieldDef {
@ -30,13 +31,14 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
public DmdFieldDefMD(DmdEcma335MetadataReader reader, uint rid, DmdType declaringType, DmdType reflectedType) : base(rid, declaringType, reflectedType) {
this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
var row = reader.TablesStream.ReadFieldRow(rid);
bool b = reader.TablesStream.TryReadFieldRow(rid, out var row);
Debug.Assert(b);
Attributes = (DmdFieldAttributes)row.Flags;
Name = reader.StringsStream.ReadNoNull(row.Name);
FieldType = reader.ReadFieldType(row.Signature, DeclaringType.GetGenericArguments());
if (HasFieldRVA) {
var rvaRow = reader.TablesStream.ReadFieldRVARow(reader.Metadata.GetFieldRVARid(rid));
FieldRVA = rvaRow?.RVA ?? 0;
reader.TablesStream.TryReadFieldRVARow(reader.Metadata.GetFieldRVARid(rid), out var rvaRow);
FieldRVA = rvaRow.RVA;
}
}
@ -45,8 +47,11 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
protected override (DmdCustomAttributeData[] cas, uint? fieldOffset, DmdMarshalType marshalType) CreateCustomAttributes() {
var marshalType = reader.ReadMarshalType(MetadataToken, ReflectedType.Module, null);
var cas = reader.ReadCustomAttributes(MetadataToken);
var row = reader.TablesStream.ReadFieldLayoutRow(reader.Metadata.GetFieldLayoutRid(Rid));
var fieldOffset = row == null ? (uint?)null : row.OffSet;
uint? fieldOffset;
if (reader.TablesStream.TryReadFieldLayoutRow(reader.Metadata.GetFieldLayoutRid(Rid), out var row))
fieldOffset = row.OffSet;
else
fieldOffset = null;
return (cas, fieldOffset, marshalType);
}
}

View File

@ -53,7 +53,8 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
var gpcList = new DmdType[ridList.Count];
for (int i = 0; i < ridList.Count; i++) {
uint rid = ridList[i];
var row = reader.TablesStream.ReadGenericParamConstraintRow(rid);
if (!reader.TablesStream.TryReadGenericParamConstraintRow(rid, out var row))
return null;
if (!CodedToken.TypeDefOrRef.Decode(row.Constraint, out uint token))
return null;
var type = Module.ResolveType((int)token, genericTypeArguments, genericMethodArguments, DmdResolveOptions.None);

View File

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using dnlib.DotNet.MD;
namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
@ -49,13 +50,12 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
var sas = reader.ReadSecurityAttributes(MetadataToken);
DmdImplMap? implMap;
if (IsPinvokeImpl) {
var row = reader.TablesStream.ReadImplMapRow(reader.Metadata.GetImplMapRid(Table.Method, Rid));
if (row == null)
if (!reader.TablesStream.TryReadImplMapRow(reader.Metadata.GetImplMapRid(Table.Method, Rid), out var row))
implMap = null;
else {
var name = reader.StringsStream.ReadNoNull(row.ImportName);
var modRow = reader.TablesStream.ReadModuleRefRow(row.ImportScope);
var module = reader.StringsStream.ReadNoNull(modRow?.Name ?? 0);
reader.TablesStream.TryReadModuleRefRow(row.ImportScope, out var modRow);
var module = reader.StringsStream.ReadNoNull(modRow.Name);
implMap = new DmdImplMap((DmdPInvokeAttributes)row.MappingFlags, name, module);
}
}
@ -65,7 +65,8 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
}
private protected override DmdMethodSignature GetMethodSignatureCore(IList<DmdType> genericMethodArguments) {
var row = reader.TablesStream.ReadMethodRow(Rid);
bool b = reader.TablesStream.TryReadMethodRow(Rid, out var row);
Debug.Assert(b);
return reader.ReadMethodSignature(row.Signature, DeclaringType.GetGenericArguments(), genericMethodArguments, isProperty: false);
}

View File

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using dnlib.DotNet;
using dnlib.DotNet.MD;
@ -32,7 +33,8 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
public DmdPropertyDefMD(DmdEcma335MetadataReader reader, uint rid, DmdType declaringType, DmdType reflectedType) : base(rid, declaringType, reflectedType) {
this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
var row = reader.TablesStream.ReadPropertyRow(rid);
bool b = reader.TablesStream.TryReadPropertyRow(rid, out var row);
Debug.Assert(b);
Name = reader.StringsStream.ReadNoNull(row.Name);
Attributes = (DmdPropertyAttributes)row.PropFlags;
methodSignature = reader.ReadMethodSignature(row.Type, DeclaringType.GetGenericArguments(), null, isProperty: true);
@ -48,8 +50,9 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
List<DmdMethodInfo> otherMethodsList = null;
var ridList = reader.Metadata.GetMethodSemanticsRidList(Table.Property, Rid);
for (uint i = 0; i < ridList.Length; i++) {
var row = reader.TablesStream.ReadMethodSemanticsRow(ridList[i]);
for (int i = 0; i < ridList.Count; i++) {
if (!reader.TablesStream.TryReadMethodSemanticsRow(ridList[i], out var row))
continue;
var method = ReflectedType.GetMethod(Module, 0x06000000 + (int)row.Method) as DmdMethodInfo;
if ((object)method == null)
continue;

View File

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using dnlib.DotNet.MD;
namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
@ -33,7 +34,8 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
public DmdTypeDefMD(DmdEcma335MetadataReader reader, uint rid, IList<DmdCustomModifier> customModifiers) : base(rid, customModifiers) {
this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
var row = reader.TablesStream.ReadTypeDefRow(rid);
bool b = reader.TablesStream.TryReadTypeDefRow(rid, out var row);
Debug.Assert(b);
string ns = reader.StringsStream.Read(row.Namespace);
MetadataNamespace = string.IsNullOrEmpty(ns) ? null : ns;
MetadataName = reader.StringsStream.ReadNoNull(row.Name);
@ -43,12 +45,16 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
public override DmdType WithCustomModifiers(IList<DmdCustomModifier> customModifiers) => AppDomain.Intern(new DmdTypeDefMD(reader, Rid, VerifyCustomModifiers(customModifiers)));
public override DmdType WithoutCustomModifiers() => GetCustomModifiers().Count == 0 ? this : AppDomain.Intern(new DmdTypeDefMD(reader, Rid, null));
protected override DmdType GetDeclaringType() =>
Module.ResolveType(0x02000000 + (int)(reader.TablesStream.ReadNestedClassRow(reader.Metadata.GetNestedClassRid(Rid))?.EnclosingClass ?? 0), DmdResolveOptions.None);
protected override DmdType GetDeclaringType() {
if (!reader.TablesStream.TryReadNestedClassRow(reader.Metadata.GetNestedClassRid(Rid), out var row))
return null;
return Module.ResolveType(0x02000000 + (int)row.EnclosingClass, DmdResolveOptions.None);
}
protected override DmdType GetBaseTypeCore(IList<DmdType> genericTypeArguments) {
uint extends = reader.TablesStream.ReadTypeDefRow(Rid).Extends;
if (!CodedToken.TypeDefOrRef.Decode(extends, out uint token))
if (!reader.TablesStream.TryReadTypeDefRow(Rid, out var row))
return null;
if (!CodedToken.TypeDefOrRef.Decode(row.Extends, out uint token))
return null;
return reader.Module.ResolveType((int)token, genericTypeArguments, null, DmdResolveOptions.None);
}
@ -60,7 +66,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
var genericParams = new DmdType[ridList.Count];
for (int i = 0; i < genericParams.Length; i++) {
uint rid = ridList[i];
var row = reader.TablesStream.ReadGenericParamRow(rid) ?? new RawGenericParamRow();
reader.TablesStream.TryReadGenericParamRow(rid, out var row);
var gpName = reader.StringsStream.ReadNoNull(row.Name);
var gpType = new DmdGenericParameterTypeMD(reader, rid, this, gpName, row.Number, (DmdGenericParameterAttributes)row.Flags, null);
genericParams[i] = gpType;
@ -125,8 +131,9 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
var res = new DmdType[ridList.Count];
for (int i = 0; i < res.Length; i++) {
uint rid = ridList[i];
var row = reader.Metadata.TablesStream.ReadInterfaceImplRow(rid);
if (row == null || !CodedToken.TypeDefOrRef.Decode(row.Interface, out uint token))
if (!reader.Metadata.TablesStream.TryReadInterfaceImplRow(rid, out var row))
return null;
if (!CodedToken.TypeDefOrRef.Decode(row.Interface, out uint token))
return null;
res[i] = Module.ResolveType((int)token, genericTypeArguments, null, DmdResolveOptions.ThrowOnError);
}
@ -155,8 +162,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
}
protected override (int packingSize, int classSize) GetClassLayout() {
var row = reader.TablesStream.ReadClassLayoutRow(reader.Metadata.GetClassLayoutRid(Rid));
if (row == null)
if (!reader.TablesStream.TryReadClassLayoutRow(reader.Metadata.GetClassLayoutRid(Rid), out var row))
return (0, 0);
return (row.PackingSize, (int)row.ClassSize);
}

View File

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using dnlib.DotNet.MD;
namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
@ -33,7 +34,8 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
public DmdTypeRefMD(DmdEcma335MetadataReader reader, uint rid, IList<DmdCustomModifier> customModifiers) : base(reader.Module, rid, customModifiers) {
this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
var row = reader.TablesStream.ReadTypeRefRow(rid);
bool b = reader.TablesStream.TryReadTypeRefRow(rid, out var row);
Debug.Assert(b);
var ns = reader.StringsStream.Read(row.Namespace);
MetadataNamespace = string.IsNullOrEmpty(ns) ? null : ns;
MetadataName = reader.StringsStream.ReadNoNull(row.Name);
@ -51,7 +53,7 @@ namespace dnSpy.Debugger.DotNet.Metadata.Impl.MD {
break;
case 0x1A:
var moduleRefRow = reader.TablesStream.ReadModuleRefRow(resScopeToken & 0x00FFFFFF) ?? new RawModuleRefRow();
reader.TablesStream.TryReadModuleRefRow(resScopeToken & 0x00FFFFFF, out var moduleRefRow);
var moduleName = reader.StringsStream.ReadNoNull(moduleRefRow.Name);
TypeScope = new DmdTypeScope(reader.GetName(), moduleName);
break;

View File

@ -261,9 +261,8 @@ namespace dnSpy.Debugger.DotNet.Mono.Impl {
}
}
else {
using (var md = MetaDataCreator.CreateMetaData(peImage)) {
var row = md.TablesStream.ReadAssemblyRow(1);
if (row == null)
using (var md = MetadataCreator.CreateMetadata(peImage)) {
if (!md.TablesStream.TryReadAssemblyRow(1, out var row))
assemblySimpleName = null;
else
assemblySimpleName = md.StringsStream.Read(row.Name);

View File

@ -120,9 +120,9 @@ namespace dnSpy.Debugger.DotNet.Metadata.Internal {
var dotNetDir = peImage.ImageNTHeaders.OptionalHeader.DataDirectories[14];
if (dotNetDir.VirtualAddress != 0 && dotNetDir.Size >= 0x48) {
var cor20 = new ImageCor20Header(peImage.CreateStream(dotNetDir.VirtualAddress, 0x48), true);
var mdStart = (long)peImage.ToFileOffset(cor20.MetaData.VirtualAddress);
var mdStart = (long)peImage.ToFileOffset(cor20.Metadata.VirtualAddress);
var mdAddr = new IntPtr((byte*)address + mdStart);
var mdSize = (int)cor20.MetaData.Size;
var mdSize = (int)cor20.Metadata.Size;
return (mdAddr, mdSize);
}
}

@ -1 +1 @@
Subproject commit 9c9f2c46341db8d23acd9fc93cff808575fcbb57
Subproject commit 67a60c2c1ea1d5e57b489fe558d3d0eae1c68171

View File

@ -39,7 +39,7 @@ namespace dnSpy.Contracts.Documents {
/// <inheritdoc/>
public virtual ModuleDef ModuleDef => null;
/// <inheritdoc/>
public virtual IPEImage PEImage => (ModuleDef as ModuleDefMD)?.MetaData?.PEImage;
public virtual IPEImage PEImage => (ModuleDef as ModuleDefMD)?.Metadata?.PEImage;
/// <inheritdoc/>
public string Filename {

View File

@ -95,7 +95,7 @@ namespace dnSpy.Contracts.Documents.TreeView.Resources {
if (module == null)
return 0;
return (uint)module.MetaData.PEImage.ToRVA(fo);
return (uint)module.Metadata.PEImage.ToRVA(fo);
}
}

View File

@ -98,7 +98,7 @@ namespace dnSpy.Contracts.Documents.TreeView.Resources {
if (module == null)
return 0;
return (uint)module.MetaData.PEImage.ToRVA(fo);
return (uint)module.Metadata.PEImage.ToRVA(fo);
}
}
@ -150,7 +150,7 @@ namespace dnSpy.Contracts.Documents.TreeView.Resources {
break;
case ResourceType.Linked:
var file = ((LinkedResource)Resource).File;
extra = string.Format("{0}, {1}, {2}", file.Name, file.ContainsNoMetaData ? "ContainsNoMetaData" : "ContainsMetaData", SimpleTypeConverter.ByteArrayToString(file.HashValue));
extra = string.Format("{0}, {1}, {2}", file.Name, file.ContainsNoMetadata ? "ContainsNoMetaData" : "ContainsMetaData", SimpleTypeConverter.ByteArrayToString(file.HashValue));
break;
case ResourceType.Embedded:
extra = string.Format(dnSpy_Contracts_DnSpy_Resources.NumberOfBytes, ((EmbeddedResource)Resource).Data.Length);

View File

@ -41,7 +41,7 @@ namespace dnSpy.Contracts.Hex.Files.DotNet {
/// <summary>IMAGE_COR20_HEADER.MinorRuntimeVersion</summary>
public abstract StructField<UInt16Data> MinorRuntimeVersion { get; }
/// <summary>IMAGE_COR20_HEADER.MetaData</summary>
public abstract StructField<DataDirectoryData> MetaData { get; }
public abstract StructField<DataDirectoryData> Metadata { get; }
/// <summary>IMAGE_COR20_HEADER.Flags</summary>
public abstract StructField<UInt32FlagsData> Flags { get; }
/// <summary>IMAGE_COR20_HEADER.EntryPointToken / IMAGE_COR20_HEADER.EntryPointRVA</summary>

View File

@ -90,7 +90,7 @@ namespace dnSpy.Contracts.Decompiler {
var m = module as ModuleDefMD;//TODO: Support CorModuleDef
if (m == null)
return null;
return (long)m.MetaData.PEImage.ToFileOffset((RVA)rva);
return (long)m.Metadata.PEImage.ToFileOffset((RVA)rva);
}
/// <summary>

View File

@ -76,7 +76,7 @@ namespace dnSpy.Decompiler {
static IPEImage TryGetPEImage(ModuleDef mod) {
var m = mod as ModuleDefMD;
return m == null ? null : m.MetaData.PEImage;
return m == null ? null : m.Metadata.PEImage;
}
protected void WriteAssembly(AssemblyDef asm, IDecompilerOutput output, DecompilationContext ctx) {

View File

@ -37,7 +37,7 @@ namespace dnSpy.Decompiler.IL {
if (m == null)
return null;
return m.MetaData.PEImage.CreateStream((RVA)rva);
return m.Metadata.PEImage.CreateStream((RVA)rva);
}
public int ReadByte() {

View File

@ -357,7 +357,7 @@ namespace dnSpy.Decompiler.MSBuild {
string GetFileAlignment() {
if (project.Module is ModuleDefMD mod)
return mod.MetaData.PEImage.ImageNTHeaders.OptionalHeader.FileAlignment.ToString();
return mod.Metadata.PEImage.ImageNTHeaders.OptionalHeader.FileAlignment.ToString();
return "512";
}

View File

@ -29,7 +29,7 @@ namespace dnSpy.Hex.Files.DotNet {
public override StructField<UInt32Data> Cb { get; }
public override StructField<UInt16Data> MajorRuntimeVersion { get; }
public override StructField<UInt16Data> MinorRuntimeVersion { get; }
public override StructField<DataDirectoryData> MetaData { get; }
public override StructField<DataDirectoryData> Metadata { get; }
public override StructField<UInt32FlagsData> Flags { get; }
public override StructField<UInt32Data> EntryPointTokenOrRVA { get; }
public override StructField<DataDirectoryData> Resources { get; }
@ -58,7 +58,7 @@ namespace dnSpy.Hex.Files.DotNet {
Cb = new StructField<UInt32Data>("cb", new UInt32Data(buffer, pos));
MajorRuntimeVersion = new StructField<UInt16Data>("MajorRuntimeVersion", new UInt16Data(buffer, pos + 4));
MinorRuntimeVersion = new StructField<UInt16Data>("MinorRuntimeVersion", new UInt16Data(buffer, pos + 6));
MetaData = new StructField<DataDirectoryData>("MetaData", new DataDirectoryData(buffer, pos + 8));
Metadata = new StructField<DataDirectoryData>("MetaData", new DataDirectoryData(buffer, pos + 8));
Flags = new StructField<UInt32FlagsData>("Flags", new UInt32FlagsData(buffer, pos + 0x10, flagsFlagInfos));
EntryPointTokenOrRVA = new StructField<UInt32Data>("EntryPointTokenOrRVA", new UInt32Data(buffer, pos + 0x14));
Resources = new StructField<DataDirectoryData>("Resources", new DataDirectoryData(buffer, pos + 0x18));
@ -71,7 +71,7 @@ namespace dnSpy.Hex.Files.DotNet {
Cb,
MajorRuntimeVersion,
MinorRuntimeVersion,
MetaData,
Metadata,
Flags,
EntryPointTokenOrRVA,
Resources,

View File

@ -147,7 +147,7 @@ namespace dnSpy.Hex.Files.DotNet {
HexSpan? GetFieldReferenceSpan(HexBufferFile file, DotNetCor20Data cor20, HexPosition position) {
HexSpan? span;
if ((span = DataDirectoryDataUtils.TryGetSpan(file, cor20.MetaData.Data, position)) != null)
if ((span = DataDirectoryDataUtils.TryGetSpan(file, cor20.Metadata.Data, position)) != null)
return span;
if ((span = DataDirectoryDataUtils.TryGetSpan(file, cor20.Resources.Data, position)) != null)
return span;

View File

@ -60,7 +60,7 @@ namespace dnSpy.Hex.Files.DotNet {
if (cor20 == null)
return false;
var mdSpan = Read(peHeaders, cor20.MetaData.Data);
var mdSpan = Read(peHeaders, cor20.Metadata.Data);
resourcesSpan = Read(peHeaders, cor20.Resources.Data);
var snSpan = Read(peHeaders, cor20.StrongNameSignature.Data);